#include using namespace std; struct QueryType { int query_type; vector> qe; string c; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k, q; cin >> n >> k >> q; vector query(q); for (int i=0;i> query[i].query_type; if (query[i].query_type == 1) { cin >> query[i].c; } else { vector> t(6); for (int j=0;j<6;++j) cin >> t[j].first >> t[j].second; query[i].qe = t; } } priority_queue, vector>, greater>> pque; int id {1}; auto check = [&](const string& s) { queue> que; bool is_find {false}; while (!pque.empty()) { pair ct = pque.top(); pque.pop(); if (ct.second == s) is_find = true; que.push(ct); } while (!que.empty()) { pair ct = que.front(); que.pop(); pque.push(ct); } return is_find; }; auto add = [&](const string& s) { queue> que; while (!pque.empty()) { pair ct = pque.top(); pque.pop(); que.push(ct); } bool is_find {false}; while (!que.empty()) { pair ct = que.front(); que.pop(); if (ct.second == s) { is_find = true; ct.first = id++; } pque.push(ct); } if (is_find == false) { pque.push(make_pair(id++, s)); if (pque.size() > n) pque.pop(); } }; for (int i=0;i 60ll) break; ++cnt; } cout << cnt << '\n'; for (const auto& e : query[i].qe) { add(e.first); } } } }