#include #include #include #include #include using namespace std; using ll = long long; using tu = tuple; int main(void){ int n, m, q; cin >> n >> m >> q; map> row; vector ans(m); while(q--){ int t; cin >> t; if(t==1){ int i, g; cin >> i >> g; i--, g--; row[g].push_back(i); } else{ int s, t; cin >> s >> t; s--, t--; int x=row[s].front(); row[s].pop_front(); ans[x]++; row[t].push_back(x); } } for(auto p:ans) cout << p << '\n'; return 0; }