#include using namespace std; int main() { int N, M, Q; cin >> N >> M >> Q; map> mp; vector cnt(M, 0); while(Q--) { int cmd; cin >> cmd; if(cmd == 1) { int i, g; cin >> i >> g, --i; mp[g].push(i); } if(cmd == 2) { int s, t; cin >> s >> t; int v = mp[s].front(); mp[s].pop(); mp[t].push(v); cnt[v] += 1; } } for(auto x : cnt) cout << x << "\n"; }