#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define GreatRevan() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define ld long double
#define pp pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define endl "\n"
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const double Pi = 3.141592653589793;
const long long MaX = 1e18;
const long long mod = 1e9 + 7;
void code(){
int n,m,v;
cin>>n>>m>>v;
vector<char> t(m, '?');
vector<pp> eq;
while (v--){
int a,b;
char c;
cin>>a>>c>>b;
a--, b--;
if (c == '<'){
t[a] = '1';
t[b] = '2';
}
else{
eq.pb({a,b});
}
}
for (auto [a,b] : eq){
if (t[a] != '?'){
t[b] = t[a];
continue;
}
if (t[b] != '?'){
t[a] = t[b];
continue;
}
}
for (int i = 0; i < m; i++){
if (t[i] == '?') cout<<'?'<<endl;
else cout<<'K'<<t[i]<<endl;
}
}
signed main(){
GreatRevan();
int tcs = 1;
//cin>>tcs;
for (int i = 1; i <= tcs; i++){
//cout<<"Case #"<<i<<": ";
code();
}
cerr<<"By GreatRevan"<<endl<<endl;
}
/*
██████╗ ███████╗███╗ ██╗ █████╗ ███████╗
██╔════╝ ██╔════╝████╗ ██║██╔══██╗██╔════╝
██║ ██╗ █████╗ ██╔██╗██║██║ ╚═╝█████╗
██║ ╚██╗██╔══╝ ██║╚████║██║ ██╗██╔══╝
╚██████╔╝███████╗██║ ╚███║╚█████╔╝███████╗
╚═════╝ ╚══════╝╚═╝ ╚══╝ ╚════╝ ╚══════╝
███████╗██████╗ ██╗████████╗██╗
██╔════╝██╔══██╗██║╚══██╔══╝██║
█████╗ ██████╔╝██║ ██║ ██║
██╔══╝ ██╔══██╗██║ ██║ ██║
██║ ██║ ██║██║ ██║ ███████╗
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝
*/
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |