#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define ll long long
#define pii pair<int, int>
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define MS(a, v) memset(a, v, sizeof a)
#define REP(i, n) for(int i = 0; i < n; ++ i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++ i)
#define FOD(i, a, b) for(int i = (a); i >= (b); -- i)
#define TSun(TZ) freopen(TZ".inp", "r", stdin), freopen(TZ".out", "w", stdout)
template<class X, class Y>
bool maximize(X & x, const Y & y){
if(x < y){
x = y;
return true;
}
else return false;
}
template<class X, class Y>
bool minimize(X & x, const Y & y){
if(x > y){
x = y;
return true;
}
else return false;
}
const int MAXN = 200005;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
int n, k, m;
vector <int> GX[MAXN], GN[MAXN];
int par[MAXN];
int find_par(int u){
if(par[u] < 0) return u;
return par[u] = find_par(par[u]);
}
bool join(int u, int v){
u = find_par(u);
v = find_par(v);
if(u == v) return false;
if(par[u] > par[v]) swap(u, v);
par[u] += par[v];
par[v] = u;
return true;
}
struct query{
char x;
int u, v;
query(int u = 0, char x = 'a', int v = 0) :
u(u), x(x), v(v) {}
void input(void){
string s; cin >> s;
// cerr << s << "\n";
int X = 0, Y = 0;
x = 'a';
REP(i, SZ(s)){
if(!(s[i] >= '0' && s[i] <= '9'))
x = s[i];
else if(x == 'a')
X = X * 10 + s[i] - '0';
else
Y = Y * 10 + s[i] - '0';
}
u = X;
v = Y;
// cout << u << " " << x << " " << v << "\n";
}
void get(int &_u, char &_x, int & _v){
_u = u;
_x = x;
_v = v;
}
}Q[MAXN];
int f[MAXN], g[MAXN];
void xuoi(int u){
f[u] = 1;
for(int v : GX[u]){
if(f[v] == -1)
xuoi(v);
maximize(f[u], f[v] + 1);
}
}
void nguoc(int u){
g[u] = 1;
for(int v : GN[u]){
if(g[v] == -1)
nguoc(v);
maximize(g[u], g[v] + 1);
}
}
void solve(void){
cin >> n >> k >> m;
FOR(i, 1, n) par[i] = -1;
FOR(i, 1, m) Q[i].input();
// return;
FOR(i, 1, m){
char x;
int u, v;
Q[i].get(u, x, v);
if(x == '=')
join(u, v);
}
FOR(i, 1, m){
char x;
int u, v;
Q[i].get(u, x, v);
u = find_par(u);
v = find_par(v);
if(x == '<'){
GX[v].PB(u);
GN[u].PB(v);
}
else if(x == '>'){
GN[v].PB(u);
GX[u].PB(v);
}
}
MS(f, -1);
MS(g, -1);
FOR(i, 1, n){
int u = find_par(i);
if(f[u] == -1)
xuoi(u);
if(g[u] == -1)
nguoc(u);
int len = f[u] + g[u] - 1;
if(len == k)
cout << char('a' + f[u] - 1);
else
cout << '?';
}
}
int main(void){
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define TaZinh "test"
if(fopen(TaZinh".inp", "r"))
TSun(TaZinh);
int Sun = 1;
// cin >> Sun;
REP(love, Sun) solve();
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBNUCBtYWtlX3BhaXIKI2RlZmluZSBQQiBwdXNoX2JhY2sKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBwaWkgcGFpcjxpbnQsIGludD4KI2RlZmluZSBTWihhKSBpbnQoYS5zaXplKCkpCiNkZWZpbmUgQUxMKGEpIGEuYmVnaW4oKSwgYS5lbmQoKQojZGVmaW5lIE1TKGEsIHYpIG1lbXNldChhLCB2LCBzaXplb2YgYSkKI2RlZmluZSBSRVAoaSwgbikgZm9yKGludCBpID0gMDsgaSA8IG47ICsrIGkpCiNkZWZpbmUgRk9SKGksIGEsIGIpIGZvcihpbnQgaSA9IChhKTsgaSA8PSAoYik7ICsrIGkpCiNkZWZpbmUgRk9EKGksIGEsIGIpIGZvcihpbnQgaSA9IChhKTsgaSA+PSAoYik7IC0tIGkpCiNkZWZpbmUgVFN1bihUWikgZnJlb3BlbihUWiIuaW5wIiwgInIiLCBzdGRpbiksIGZyZW9wZW4oVFoiLm91dCIsICJ3Iiwgc3Rkb3V0KQoKdGVtcGxhdGU8Y2xhc3MgWCwgY2xhc3MgWT4KICAgICAgICBib29sIG1heGltaXplKFggJiB4LCBjb25zdCBZICYgeSl7CiAgICAgICAgICAgICAgICBpZih4IDwgeSl7CiAgICAgICAgICAgICAgICAgICAgICAgIHggPSB5OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KCnRlbXBsYXRlPGNsYXNzIFgsIGNsYXNzIFk+CiAgICAgICAgYm9vbCBtaW5pbWl6ZShYICYgeCwgY29uc3QgWSAmIHkpewogICAgICAgICAgICAgICAgaWYoeCA+IHkpewogICAgICAgICAgICAgICAgICAgICAgICB4ID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIHJldHVybiBmYWxzZTsKICAgICAgICB9Cgpjb25zdCBpbnQgTUFYTiA9IDIwMDAwNTsKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7CmNvbnN0IGxsIElORiA9IDFlMTg7CgppbnQgbiwgaywgbTsKdmVjdG9yIDxpbnQ+IEdYW01BWE5dLCBHTltNQVhOXTsKCmludCBwYXJbTUFYTl07CgppbnQgZmluZF9wYXIoaW50IHUpewogICAgICAgIGlmKHBhclt1XSA8IDApIHJldHVybiB1OwogICAgICAgIHJldHVybiBwYXJbdV0gPSBmaW5kX3BhcihwYXJbdV0pOwp9Cgpib29sIGpvaW4oaW50IHUsIGludCB2KXsKICAgICAgICB1ID0gZmluZF9wYXIodSk7CiAgICAgICAgdiA9IGZpbmRfcGFyKHYpOwogICAgICAgIGlmKHUgPT0gdikgcmV0dXJuIGZhbHNlOwogICAgICAgIGlmKHBhclt1XSA+IHBhclt2XSkgc3dhcCh1LCB2KTsKICAgICAgICBwYXJbdV0gKz0gcGFyW3ZdOwogICAgICAgIHBhclt2XSA9IHU7CiAgICAgICAgcmV0dXJuIHRydWU7Cn0KCnN0cnVjdCBxdWVyeXsKCiAgICAgICAgY2hhciB4OwogICAgICAgIGludCB1LCB2OwogICAgICAgIHF1ZXJ5KGludCB1ID0gMCwgY2hhciB4ID0gJ2EnLCBpbnQgdiA9IDApIDoKICAgICAgICAgICAgICAgIHUodSksIHgoeCksIHYodikge30KCiAgICAgICAgdm9pZCBpbnB1dCh2b2lkKXsKCiAgICAgICAgICAgICAgICBzdHJpbmcgczsgY2luID4+IHM7Ci8vICAgICAgICAgICAgICAgIGNlcnIgPDwgcyA8PCAiXG4iOwoKICAgICAgICAgICAgICAgIGludCBYID0gMCwgWSA9IDA7CgogICAgICAgICAgICAgICAgeCA9ICdhJzsKCiAgICAgICAgICAgICAgICBSRVAoaSwgU1oocykpewogICAgICAgICAgICAgICAgICAgICAgICBpZighKHNbaV0gPj0gJzAnICYmIHNbaV0gPD0gJzknKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBpZih4ID09ICdhJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBYID0gWCAqIDEwICsgc1tpXSAtICcwJzsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFkgPSBZICogMTAgKyBzW2ldIC0gJzAnOwogICAgICAgICAgICAgICAgfQoKCiAgICAgICAgICAgICAgICB1ID0gWDsKICAgICAgICAgICAgICAgIHYgPSBZOwoKLy8gICAgICAgICAgICAgICAgY291dCA8PCB1IDw8ICIgIiA8PCB4IDw8ICIgIiA8PCB2IDw8ICJcbiI7CgogICAgICAgIH0KCiAgICAgICAgdm9pZCBnZXQoaW50ICZfdSwgY2hhciAmX3gsIGludCAmIF92KXsKICAgICAgICAgICAgICAgIF91ID0gdTsKICAgICAgICAgICAgICAgIF94ID0geDsKICAgICAgICAgICAgICAgIF92ID0gdjsKICAgICAgICB9Cgp9UVtNQVhOXTsKCmludCBmW01BWE5dLCBnW01BWE5dOwoKdm9pZCB4dW9pKGludCB1KXsKICAgICAgICBmW3VdID0gMTsKICAgICAgICBmb3IoaW50IHYgOiBHWFt1XSl7CiAgICAgICAgICAgICAgICBpZihmW3ZdID09IC0xKQogICAgICAgICAgICAgICAgICAgICAgICB4dW9pKHYpOwogICAgICAgICAgICAgICAgbWF4aW1pemUoZlt1XSwgZlt2XSArIDEpOwogICAgICAgIH0KfQoKdm9pZCBuZ3VvYyhpbnQgdSl7CiAgICAgICAgZ1t1XSA9IDE7CiAgICAgICAgZm9yKGludCB2IDogR05bdV0pewogICAgICAgICAgICAgICAgaWYoZ1t2XSA9PSAtMSkKICAgICAgICAgICAgICAgICAgICAgICAgbmd1b2Modik7CiAgICAgICAgICAgICAgICBtYXhpbWl6ZShnW3VdLCBnW3ZdICsgMSk7CiAgICAgICAgfQp9Cgp2b2lkIHNvbHZlKHZvaWQpewogICAgICAgIGNpbiA+PiBuID4+IGsgPj4gbTsKICAgICAgICBGT1IoaSwgMSwgbikgcGFyW2ldID0gLTE7CiAgICAgICAgRk9SKGksIDEsIG0pIFFbaV0uaW5wdXQoKTsKCi8vICAgICAgICByZXR1cm47CgogICAgICAgIEZPUihpLCAxLCBtKXsKICAgICAgICAgICAgICAgIGNoYXIgeDsKICAgICAgICAgICAgICAgIGludCB1LCB2OwogICAgICAgICAgICAgICAgUVtpXS5nZXQodSwgeCwgdik7CiAgICAgICAgICAgICAgICBpZih4ID09ICc9JykKICAgICAgICAgICAgICAgICAgICAgICAgam9pbih1LCB2KTsKICAgICAgICB9CgogICAgICAgIEZPUihpLCAxLCBtKXsKICAgICAgICAgICAgICAgIGNoYXIgeDsKICAgICAgICAgICAgICAgIGludCB1LCB2OwogICAgICAgICAgICAgICAgUVtpXS5nZXQodSwgeCwgdik7CgogICAgICAgICAgICAgICAgdSA9IGZpbmRfcGFyKHUpOwogICAgICAgICAgICAgICAgdiA9IGZpbmRfcGFyKHYpOwoKICAgICAgICAgICAgICAgIGlmKHggPT0gJzwnKXsKICAgICAgICAgICAgICAgICAgICAgICAgR1hbdl0uUEIodSk7CiAgICAgICAgICAgICAgICAgICAgICAgIEdOW3VdLlBCKHYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSBpZih4ID09ICc+Jyl7CiAgICAgICAgICAgICAgICAgICAgICAgIEdOW3ZdLlBCKHUpOwogICAgICAgICAgICAgICAgICAgICAgICBHWFt1XS5QQih2KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIE1TKGYsIC0xKTsKICAgICAgICBNUyhnLCAtMSk7CgogICAgICAgIEZPUihpLCAxLCBuKXsKCiAgICAgICAgICAgICAgICBpbnQgdSA9IGZpbmRfcGFyKGkpOwogICAgICAgICAgICAgICAgaWYoZlt1XSA9PSAtMSkKICAgICAgICAgICAgICAgICAgICAgICAgeHVvaSh1KTsKICAgICAgICAgICAgICAgIGlmKGdbdV0gPT0gLTEpCiAgICAgICAgICAgICAgICAgICAgICAgIG5ndW9jKHUpOwoKICAgICAgICAgICAgICAgIGludCBsZW4gPSBmW3VdICsgZ1t1XSAtIDE7CgogICAgICAgICAgICAgICAgaWYobGVuID09IGspCiAgICAgICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgY2hhcignYScgKyBmW3VdIC0gMSk7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgJz8nOwogICAgICAgIH0KfQoKaW50IG1haW4odm9pZCl7CgogICAgICAgIGlvc19iYXNlIDo6IHN5bmNfd2l0aF9zdGRpbygwKTsKICAgICAgICBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKCiAgICAgICAgI2RlZmluZSBUYVppbmggInRlc3QiCgogICAgICAgIGlmKGZvcGVuKFRhWmluaCIuaW5wIiwgInIiKSkKICAgICAgICAgICAgICAgIFRTdW4oVGFaaW5oKTsKCiAgICAgICAgaW50IFN1biA9IDE7Ci8vICAgICAgICBjaW4gPj4gU3VuOwogICAgICAgIFJFUChsb3ZlLCBTdW4pIHNvbHZlKCk7CgogICAgICAgIHJldHVybiAwOwp9Cgo=