The game of Sevens! Who said what?
Haskell, 151 bytes
s n|elem '7'(show n)||mod n 7==0=(0-)|0&lt;1=id
a=scanl1(+)$map($1)$scanl(.)id$map s[1..]
f m n=mapM_ print[[x+1|x&lt;-[0..m-1],mod(a!!x-1)n==i]|i&lt;-[0..n-1]]

*Main&gt; f 30 5
[1,6,8,13,15,19,23,30]
[2,7,12,16,18,24]
[3,11,17,25]
[4,10,21,26,28]
[5,9,14,20,22,27,29]