Problem:
 Score : 1000 points    Problem Statement Select any integer N between 1000 and 2000 (inclusive), and any integer K not less than 1 , then solve the problem below.  Problem  We have N sheets of paper.
Write K integers on each of them to satisfy the following conditions:   Each integer written must be between 1 and N (inclusive).  The K integers written on the same sheet must be all different.  Each of the integers between 1 and N must be written on exactly K sheets.  For any two sheet, there is exactly one integer that appears on both.         Input There is no input in this problem.      Output In the first line, print N and K separated by a space.  In the subsequent N lines, print your solution.
The i -th of these lines must contain the K integers written on the i -th sheet, with spaces in between.        Sample Output 3 2
1 2
2 3
3 1  This is an example of a solution for N = 3 and K = 2 .  Note that this output will be judged as incorrect, since the constraint on N is not satisfied.

Solution (Python):
k=42
n=k*(k-1)+1
print n,k
for i in xrange(k) :
    for t in xrange(i*(k-1),(i+1)*(k-1)) :
        print t+1,
    print n

for i in xrange(k-1) :
    for d in xrange(k-1) :
        p=d
        for j in xrange(1,k) :
            p=(p+i)%(k-1)
            print j*(k-1)+p+1,
        print i+1

Solution (Python):
k = 38
n = k + (k - 1) * (k - 1)
v = [[] for i in xrange(n)]
for i in xrange(k):
    v[i].append(1)
    s = i * (k - 1) + 2
    for j in xrange(s, s + k - 1):
        v[i].append(j)
for i in xrange(2, k + 1):
    s = k + (i - 2) * (k - 1)
    for j in xrange(s, s + k - 1):
        v[j].append(i)
for i in xrange(k - 1):
    for x in xrange(k - 1):
        g = k + 1 + i * (k - 1) + x
        p = x
        for y in xrange(k - 1):
            v[k+y*(k-1)+p].append(g)
            p += i
            if p >= k - 1:
                p -= k - 1
print n, k
for i in xrange(n):
    print " ".join(map(str, v[i]))