//AOJ 0514: QUality Checking
#include <iostream>
using namespace std;
int a, b, c, n, test[1000][4], part[301], jud, jud2;
int main() {
	while (cin >> a >> b >> c){
		cin >> n;
		for (int i = 1; i < a + b + c; i++){
			part[i] = 2;
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 4; j++){
				cin >> test[i][j];
			}
			if (test[i][3] == 1){
				for (int j = 0; j < 3; j++){
					part[test[i][j]] = 1;
				}
			}
		}
		for (int i = 0; i < n; i++){
			if (test[i][3] == 0){
				jud = 0;
				jud2 = 0;
				for (int j = 0; j < 3; j++){
					if (part[test[i][j]] == 1)
						jud++;
					else
						jud2 = j;
				}
				if (jud == 2)
					part[test[i][jud2]] = 0;
			}
		}
		for (int i = 1; i <= a + b + c; i++){
			cout << part[i] << endl;
		}
	}
	return 0;
}