n = int(eval(input()))

for _ in range(n):

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

    out = [0]*n

    for i in range(u[1]): out[u[i+2]-1] = 1

    print((*out))
n = int(eval(input()))

for _ in range(n):

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

    out = [0]*n

    for i in u[2:]: out[i-1] = 1

    print((*out))
n = int(eval(input()))
for _ in range(n):
    u = list(map(int, input().split()))
    out = [0] * n
    for i in range(u[1]):
        out[u[i + 2] - 1] = 1
    print((*out))

n = int(eval(input()))
for _ in range(n):
    u = list(map(int, input().split()))
    out = [0] * n
    for i in u[2:]:
        out[i - 1] = 1
    print((*out))

-    for i in range(u[1]): -        out[u[i + 2] - 1] = 1 +    for i in u[2:]: +        out[i - 1] = 1