from pickle import FALSE, TRUE from re import M from tkinter.tix import Tree BIGMAP = [] for _ in range(50): BIGMAP.append([0,1,1]*100) BIGMAP.append([1,2,2]*100) BIGMAP.append([1,2,2]*100) T = int(input()) for _ in range(T): H,W = map(int, input().split()) hoff = 0 woff = 0 if H%3==2: hoff+=1 if W%3==2: woff+=1 MAP = [] for i in range(hoff,H+hoff): MAP.append(BIGMAP[i][woff:W+woff]) for m in MAP: print(*m)