import itertools import sys li = [] for i in range(0,10): print(str(i) + " " + str(i) + " " + str(i) + " " + str(i)) ss = input().split() x = int(ss[0]) y = int(ss[1]) if x == 4: sys.exit() if x > 0: for j in range(x): li.append(i) a = list(itertools.permutations(range(4))) for i in a: print(str(li[i[0]]) + " " + str(li[i[1]]) + " " + str(li[i[2]]) + " " + str(li[i[3]])) ss = input().split() if ss[0] == "4": sys.exit()