// #define _GLIBCXX_DEBUG #include using namespace std; #include using namespace atcoder; using ll = long long; #define rep(i,n) for (ll i = 0; i < (n); ++i) using vl = vector; using vvl = vector; using P = pair; #define pb push_back #define int long long #define double long double #define INF (ll) 3e18 // Ctrl + Shift + B コンパイル // Ctrl + C 中断 // ./m 実行 signed main(){ int n, k, q; cin >> n >> k >> q; deque deq; while(q--){ int t; cin >> t; if (t == 1){ string d; cin >> d; deq.push_back(d); } if (t == 2){ vector t(6); vl d(6); rep(i, 6) cin >> t[i] >> d[i]; int solve = 0; int time = 0; rep(i, 6){ int find = 0; for(auto x : deq) if (x == t[i]) find = 1; if (find) time += min(d[i], k); else time += d[i]; if (time <= 60) solve++; } cout << solve << endl; rep(i, 6) deq.push_back(t[i]); } while(deq.size() > n) deq.pop_front(); } }