One day Ms Swan bought an orange in a shop. The orange consisted of n·k segments, numbered with integers from 1 to n·k. 

There were k children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper and wrote the number of the segment that he would like to get: the i-th (1 ≤ i ≤ k) child wrote the number a_{i} (1 ≤ a_{i} ≤ n·k). All numbers a_{i} accidentally turned out to be different.

Now the children wonder, how to divide the orange so as to meet these conditions:  each child gets exactly n orange segments;  the i-th child gets the segment with number a_{i} for sure;  no segment goes to two children simultaneously. 

Help the children, divide the orange and fulfill the requirements, described above.


-----Input-----

The first line contains two integers n, k (1 ≤ n, k ≤ 30). The second line contains k space-separated integers a_1, a_2, ..., a_{k} (1 ≤ a_{i} ≤ n·k), where a_{i} is the number of the orange segment that the i-th child would like to get.

It is guaranteed that all numbers a_{i} are distinct.


-----Output-----

Print exactly n·k distinct integers. The first n integers represent the indexes of the segments the first child will get, the second n integers represent the indexes of the segments the second child will get, and so on. Separate the printed numbers with whitespaces.

You can print a child's segment indexes in any order. It is guaranteed that the answer always exists. If there are multiple correct answers, print any of them.


-----Examples-----
Input
2 2
4 1

Output
2 4 
1 3 

Input
3 1
2

Output
3 2 1

Difficulty: interview

Starter code:

Solutions:
#CF Round 150. Div II Prob. A - Dividing Orange
import sys

In = sys.stdin
n, k = [int(x) for x in In.readline().split()]
arr, s, cnt = [int(x) for x in In.readline().split()], set(), 1;
s.update(arr)
for i in range(k):
    c = [arr[i]]
    for j in range(n - 1):
        while (cnt in s):
            cnt += 1;
        c.append(cnt)
        cnt += 1;
    sep = ' '
    print (sep.join(map(str, c)))

import sys
f = sys.stdin
#f = open("input.txt", "r")
n, k = map(int, f.readline().strip().split())
a = [int(i) for i in f.readline().strip().split()]
num = [True] * n*k
for i in a:
    num[i-1] = False
for i in a:
    print(i, end=" ")
    cnt = 1
    for j in range(1, n*k+1):
        if cnt < n:
            if num[j-1]:
                num[j-1] = False
                print(j, end=" ")
                cnt += 1
        else:
            break
    print()

k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
b = a + [n * k + 1]
b.sort()
j = 1
t = []
for i in b:
    t += list(range(j, i))
    j = i + 1
x = 0
k -= 1
for i in range(n):
    print(str(a[i]) + ' ' + ' '.join(str(j) for j in t[x: x + k]))
    x += k


##l = [int(item) for item in input().split()]
def children_to_slices(n, k, l):
    kid_to_slice = [[]] * (k+1)
    remaining = set([i for i in range(1, (n*k)+1)])

    # Give eah kid what he wants
    for item in l:
        kid_to_slice[item[0]] = kid_to_slice[item[0]] + [item[1]]
        remaining.remove(item[1])

    # fill each kid's inventory
    for i in range(1, k+1):
        while len(kid_to_slice[i]) < n:
            kid_to_slice[i] = kid_to_slice[i] + [remaining.pop()]

    return kid_to_slice

first_line = input().split()
n = int(first_line[0])
k = int(first_line[1])
l = []
assignments = [int(item) for item in input().split()]
for i in range(len(assignments)):
        l.append((i+1, assignments[i]))

m = children_to_slices(n, k, l)
for i in range(1, k+1):
    output = ""
    for item in m[i]:
        output += str(item) + " "
    print(output)


n,k=map(int,input().split())

L=list(map(int,input().split()))

Taken=[False]*(n*k+1)

for item in L:
    Taken[item]=True
ind=1
for i in range(k):
    cnt=1
    print(L[i],end=" ")
    
    while(cnt<n):
        while(Taken[ind]):
            ind+=1
        
        print(ind,end=" ")
        ind+=1
        cnt+=1
    print()


n, k = map(int,input().split())
a = list(map(int,input().split()))
b = [[] for i in range(0,k+1)]
u = [0]*(n*k+1)
for i in range(k):
    b[i].append(a[i])
    u[a[i]]=1
p = 0;
for i in range (1,n*k+1):
    if u[i]==0:
        u[i]=1
        b[p].append(i)
    if len(b[p]) == n:
        p += 1
for i in range(k):
    for j in range(n):
        print(b[i][j],end=' ')
    print()


import sys
import math
  
n, k = [int(x) for x in (sys.stdin.readline()).split()]
an = [int(x) for x in (sys.stdin.readline()).split()]

k = [0] * (n * k) 
for i in an:
    k[i - 1] = 1
 
j = 0   
for i in an:
    v = []
    count = 0
    
    while(count != n - 1):
        if(k[j] != 1):
            v.append(str(j + 1))
            count += 1
        j += 1
    v.append(str(i))
    print(" ".join(v))

n, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
s = set(range(1, n * k + 1))
for ai in a:
    s.remove(ai)
for ai in a:
    print(ai, end='')
    for i in range(n - 1):
        print(' ' + str(s.pop()), end='')
    print()

c = 1


def main():
    n, k = map(int, input().split())
    l = list(range(1, n * k + 1))
    aa = list(map(int, input().split()))
    for a in aa:
        l[a - 1] = 0
    res, it = [], iter(filter(None, l))
    n -= 1
    for a in aa:
        res.append(a)
        for _ in range(n):
            res.append(next(it))
        print(' '.join(map(str, res)))
        res.clear()


def __starting_point():
    main()
__starting_point()

def main():
    n, k = map(int, input().split())
    l = list(range(1, n * k + 1))
    aa = list(map(int, input().split()))
    for a in aa:
        l[a - 1] = False
    l = list(filter(None, l))
    n -= 1
    for i, a in enumerate(aa):
        print(a, *l[i * n:(i + 1) * n])


def __starting_point():
    main()
__starting_point()

I=lambda:map(int,input().split())
n,k=I();a=list(I());b=list(range(1,n*k+1))
for i in a:b.remove(i)
for i in range(k):
    print(' '.join(map(str,[a[i]]+b[i*(n-1):i*(n-1)+n-1])))

n, k = [int(i) for i in input().split()]
s = set(range(1,n*k+1))
a = [set([int(i)]) for i in input().split()]
for aa in a:
    s -= aa
for i in range(k):
    for j in range(n-len(a[i])):
        a[i].add(s.pop())
    print(' '.join([str(j) for j in list(a[i])]))


n,m=map(int,input().split())
a=list(map(int,input().split()))
o=[]
for i in range(n*m):o.append(0)
for i in range(m):o[a[i]-1]=i+1
for i in range(m):
	for j in range(n-1):
		for k in range(n*m):
			if(o[k]==0):
				print(k+1,end=' ')
				o[k]=i+1
				break
	print(a[i],end='\n')	


n, k = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
box = [0 for i in range(n * k)]
a, b = 0, n * k
for i in range(k):
    box[data[i] - 1] = 1
    print(data[i], end = ' ')
    c = 1
    for j in range(a, b):
        if box[j] == 0 and c < n and (not j + 1 in data):
            print(j + 1, end = ' ')
            box[j] = 1
            c += 1
        elif c == n:
            a = j
            break
    print()
            
            
    

n,k=[int(i) for i in input().split()]
segment=list(range(1,n*k+1))
for i in range(n*k):
    segment[i]=str(segment[i])

num=[int(i) for i in input().split()]

for i in num:
    segment.remove(str(i))

t=0
for i in num:
    print(i,' '.join(segment[t:t+n-1]))
    t+=n-1


n,k=map(int,input().split())
compulsory=list(map(int,input().split()))

answer=[[] for _ in range(1000)]
mark=[False for _ in range(1000)]


for i in range(len(compulsory)):
    mark[compulsory[i]]=True
    answer[i].append(compulsory[i])

#print(answer)   
k1=0
j=0
for i in range(1,n*k+1):
    if mark[i]:
        continue
    answer[k1].append(i)
    j+=1
    if j%(n-1)==0:
        k1+=1

for i in range(k):
    for temp in answer[i]:
        print(temp,end=" ")
    print()
    


n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = [False] * (n*k+1)
for ai in a:
    s[ai]=True

for kid in range(k):
    curN = 1
    print(a[kid],end=" ")
    for num in range(n-1):
        while s[curN]: curN+=1
        s[curN] = True
        print(curN,end=" ")
    print("")
    
        
    





(n, k) = list(map(int, input().split(' ')))
a = list(input().split(' '))
s = set(a)

o = []

for i in range(k):
    o.append([a[i]])

for i in range(n * k):
    num = str(i + 1)
    j = 0
    if num not in s:
        while len(o[j]) == n:
            j += 1
        o[j].append(num)

for x in o:
    print(' '.join(x))


n,k=input().strip().split(' ')
n,k=(int(n),int(k))
list1=list(map(int,input().strip().split(' ')))
ls=[x for x in range(1,n*k+1)]
for i in range(k):
    ls.remove(list1[i])
list2=[]
i=0
j=0
while j<k:
    print(*(ls[i:i+n-1]+[list1[j]]))
    i+=(n-1)
    j+=1

arr = input().split()
n = int(arr[0])
k = int(arr[1])
arr = input().split()
s = set()
for ch in arr:
	s.add(int(ch))
for ch in arr:
	print(ch, end = ' ')
	ctr = 0
	ptr = 1
	while ctr < n - 1:
		if ptr not in s:
			print(str(ptr), end = ' ')
			ctr += 1
			s.add(ptr)
		ptr += 1
	print('')