#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define inf 9000000000000000000
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto& a : x)
int main(){
ios::sync_with_stdio(0);
ll n,k,m,x,c = 0;
char t;
cin >> n >> k >> m;
vi xs,tp;
rep(i,0,m){
cin >> t >> x; x--;
if (t == 'C') tp.push_back(1);
else tp.push_back(0);
xs.push_back(x);
}
if (k == 2 && m <= 10){
rep(tmp,0,(1<<m)){
ans.assign(m,0);
rep(i,0,m){
if (tmp&(1<<i)) ans[i] = 1;
else ans[i] = 2;
}
vector<vi> prisons;
vi _,fre;
prisons.assign(m,_);
fre.assign(m,1);
bool works = true;
rep(i,0,m){
if (tp[i]){
if (fre[xs[i]]) { fre[xs[i]] = 0; prisons[ans[i]-1].push_back(xs[i]); }
else { works = false; break; }
} else {
if (!fre[xs[i]]) { works = false; break; }
if (sz(prisons[ans[i]-1]) == 0) { works = false; break; }
trav(x,prisons[ans[i]-1]) fre[x] = 1;
prisons[ans[i]-1].clear();
}
}
if (works) {
rep(i,0,m) cout << ans[i] << " ";
cout << endl;
exit(0);
}
}
cout << "IMPOSSIBLE" << endl;
}
vi lst,prev,ans,cnt;
set<ll> os,cur;
lst.assign(n,-1);
prev.assign(m,-1);
ans.assign(m,-1);
cnt.assign(m,0);
rep(i,0,m){
if (lst[xs[i]] != -1) prev[i] = lst[xs[i]];
if (tp[i] == 0) { ans[i] = (c%k)+1; cnt[i] = c; c++; os.insert(i); cur.insert(i); }
else lst[xs[i]] = i;
}
cur.insert(m+10);
os.insert(m+10);
//rep(i,0,m) cout << prev[i] << " "; cout << endl;
//rep(i,0,m) cout << ans[i] << " "; cout << endl;
rep(i,0,m){
//trav(i,os) cout << i << " "; cout << endl;
//trav(i,cur) cout << i << " "; cout << endl;
if (prev[i] == -1) continue;
ll hi = i, lo = prev[i];
set<ll>::iterator a = upper_bound(all(cur),lo);
set<ll>::iterator _a = lower_bound(all(os),hi);
set<ll>::iterator b = upper_bound(all(os),lo);
set<ll>::iterator c = lower_bound(all(os),(*a));
//cout << " " << (*a) << " " << (*_a) << endl;
if (cnt[(*c)]-cnt[(*b)] >= k) { ans[lo] = ans[(*b)]; cout << "hej1" << endl; }
else if ((*a) >= (*_a)) { ans[lo] = ans[(*b)]; cout << "hej2" << endl; }
else { ans[lo] = ans[(*a)]; cur.erase(a); }
}
rep(i,0,m) if (ans[i] == -1) ans[i] = 1;
vector<vi> prisons;
vi _,fre;
prisons.assign(m,_);
fre.assign(m,1);
rep(i,0,m){
if (tp[i]){
if (fre[xs[i]]) { fre[xs[i]] = 0; prisons[ans[i]-1].push_back(xs[i]); }
else { cout << "IMPOSSIBLE" << endl; exit(0); }
} else {
if (!fre[xs[i]]) { cout << "IMPOSSIBLE" << endl; exit(0); }
if (sz(prisons[ans[i]-1]) == 0) { cout << "IMPOSSIBLE" << endl; exit(0); }
trav(x,prisons[ans[i]-1]) fre[x] = 1;
prisons[ans[i]-1].clear();
}
}
rep(i,0,m) cout << ans[i] << " ";
cout << endl;
}