#include using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; using i128 = __int128; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, M, Q; std::cin >> N >> M >> Q; std::unordered_map> q(N + 1); std::vector ans(M + 1); while (Q--) { int op, x, y; std::cin >> op >> x >> y; if (op == 1) { //! 人x排到y末尾 q[y].push_back(x); } else { //! x队头购买商品,然后到t末尾 int z = q[x].front(); q[x].pop_front(); ans[z]++; q[y].push_back(z); } } for (int i = 1; i <= M; i++) { std::cout << ans[i] << '\n'; } return 0; }