#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M,Q; cin >> N >> M >> Q; vector answer(M); map> Qs; while(Q--){ int t; cin >> t; if(t == 1){ int p,g; cin >> p >> g,p--; Qs[g].push(p); } else{ int a,b; cin >> a >> b; answer.at(Qs[a].front())++; Qs[b].push(Qs[a].front()),Qs[a].pop(); } } for(auto a : answer) cout << a << "\n"; }