#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int a, b, c;
    cin >> a >> b >> c;
    int M = a + b + c;
    if (!M) return 0;
    int P[300];
    for (int i = 1; i <= M; i++)
      P[i] = 2;
    int N;
    cin >> N;
    int L[1000][4];
    for (int x = 0; x < N; x++) {
      for (int j = 0; j < 4; j++)
        cin >> L[x][j];
      if (L[x][3])
        for (int j = 0; j < 3; j++)
          P[L[x][j]] = 1;
    }
    for (int x = 0; x < N; x++)
      if (!L[x][3]) {
        if (P[L[x][0]] == 1 && P[L[x][1]] == 1)
          P[L[x][2]] = 0;
        else if (P[L[x][1]] == 1 && P[L[x][2]] == 1)
          P[L[x][0]] = 0;
        else if (P[L[x][2]] == 1 && P[L[x][0]] == 1)
          P[L[x][1]] = 0;
      }
    for (int i = 1; i <= M; i++)
      cout << P[i] << endl;
  }
}