while 1:

    a, b, c = list(map(int, input().split()))

    if not a:

        break

    n = eval(input())



    I = []; J = []; K = []

    res = [2]*(a+b+c)

    for p in range(n):

        i, j, k, r = list(map(int, input().split()))

        i -= 1; j -= 1; k -= 1

        if r:

            res[i] = res[j] = res[k] = 1

        else:

            I.append(i); J.append(j); K.append(k)

    for p in range(len(I)):

        i, j, k = I[p], J[p], K[p]

        if res[i]==res[j]==res[k]==1:

            continue

        if res[i]==res[j]==1:

            res[k] = 0

        elif res[j]==res[k]==1:

            res[i] = 0

        elif res[k]==res[i]==1:

            res[j] = 0

    for i in range(a+b+c):

        print(res[i])
while 1:

    a, b, c = list(map(int, input().split()))

    if not a:

        break

    I = []

    res = [2]*(a+b+c)

    for p in range(int(input())):

        i, j, k, r = list(map(int, input().split()))

        i -= 1; j -= 1; k -= 1

        if r:

            res[i] = res[j] = res[k] = 1

        else:

            I.append((i, j, k))

    for e in I:

        i, j, k = e

        if res[i]+res[j]+res[k]!=4:

            continue

        if res[i]==2:

            res[i] = -1

        elif res[j]==2:

            res[j] = -1

        else:

            res[k] = -1

    for i in range(a+b+c):

        print(res[i] if res[i]>=0 else 0)
while 1:
    a, b, c = list(map(int, input().split()))
    if not a:
        break
    n = eval(input())
    I = []
    J = []
    K = []
    res = [2] * (a + b + c)
    for p in range(n):
        i, j, k, r = list(map(int, input().split()))
        i -= 1
        j -= 1
        k -= 1
        if r:
            res[i] = res[j] = res[k] = 1
        else:
            I.append(i)
            J.append(j)
            K.append(k)
    for p in range(len(I)):
        i, j, k = I[p], J[p], K[p]
        if res[i] == res[j] == res[k] == 1:
            continue
        if res[i] == res[j] == 1:
            res[k] = 0
        elif res[j] == res[k] == 1:
            res[i] = 0
        elif res[k] == res[i] == 1:
            res[j] = 0
    for i in range(a + b + c):
        print(res[i])

while 1:
    a, b, c = list(map(int, input().split()))
    if not a:
        break
    I = []
    res = [2] * (a + b + c)
    for p in range(int(input())):
        i, j, k, r = list(map(int, input().split()))
        i -= 1
        j -= 1
        k -= 1
        if r:
            res[i] = res[j] = res[k] = 1
        else:
            I.append((i, j, k))
    for e in I:
        i, j, k = e
        if res[i] + res[j] + res[k] != 4:
            continue
        if res[i] == 2:
            res[i] = -1
        elif res[j] == 2:
            res[j] = -1
        else:
            res[k] = -1
    for i in range(a + b + c):
        print(res[i] if res[i] >= 0 else 0)

-    n = eval(input()) -    J = [] -    K = [] -    for p in range(n): +    for p in range(int(input())): -            I.append(i) -            J.append(j) -            K.append(k) -    for p in range(len(I)): -        i, j, k = I[p], J[p], K[p] -        if res[i] == res[j] == res[k] == 1: +            I.append((i, j, k)) +    for e in I: +        i, j, k = e +        if res[i] + res[j] + res[k] != 4: -        if res[i] == res[j] == 1: -            res[k] = 0 -        elif res[j] == res[k] == 1: -            res[i] = 0 -        elif res[k] == res[i] == 1: -            res[j] = 0 +        if res[i] == 2: +            res[i] = -1 +        elif res[j] == 2: +            res[j] = -1 +        else: +            res[k] = -1 -        print(res[i]) +        print(res[i] if res[i] >= 0 else 0)