main=(putStr . unlines) (f 3 c) c=[31,29,31,30,31,30,31,31,30,31,30,31] s n|n<10=" "++show n s n=show n g []=[] g x=let(a,b)=splitAt 7 x in (' ':unwords a):g b f n []=[] f n(x:xs)=g m++("":f (mod (length m) 7) xs)where m=replicate n" "++map s[1..x]