#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n, m, q; cin >> n >> m >> q; map> qu; vector ans(m, 0); while (q--) { int t; cin >> t; if (t == 1) { int i, g; cin >> i >> g; i--; qu[g].push(i); } else { int s, t; cin >> s >> t; int f = qu[s].front(); qu[s].pop(); ans[f]++; qu[t].push(f); } } for (int i : ans) cout << i << endl; return 0; }