#include <iostream>
#include<vector>
#include <string>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
vector<int> thief(a+1);
for (int i = 1; i < a+1; i++) {
thief[i] = i;
}
vector<string> move1(c);
vector<int> move2(c);
for(int i = 0; i < c; i++) {
cin >> move1[i] >> move2[i];
}
for (int i = 0; i < pow(2, c); i++) {
for (int i = 1; i < a + 1; i++) {
thief[i] = i;
}
vector<vector<int>> pris(2, vector<int>(10,0));
int p = 0;
int q = 0;
for (int j = 0; j < c; j++) {
if (move1[j] == "C" && thief[move2[j]] != 0 ) {
if ((i >> j) & 1) {
pris[1][p] = move2[j];
p++;
thief[move2[j]] = 0;
}
else {
pris[0][q] = move2[j];
q++;
thief[move2[j]] = 0;
}
}
else if(move1[j] == "O" && thief[move2[j]] !=0){
if ((i >> j) && 1 && pris[1][0] != 0) {
for (int l = 0; l < pris[1].size(); l++) {
thief[pris[1][l]] = pris[1][l];
pris[1][l] = 0;
}
p = 0;
}
else if (pris[0][0] != 0) {
for (int l = 0; l < pris[0].size(); l++) {
thief[pris[0][l]] = pris[0][l];
pris[0][l] = 0;
}
q = 0;
}
else {
break;
}
}
else {
break;
}
if (j == c-1) {
for (int h = 0; h < c; h++) {
if ((i >> h) && 1) {
cout << 2 << " ";
}
else {
cout << 1 << " "; }
}
return 0;
}
}
}
cout << "IMPOSSIBLE";
return 0;
}