#include using namespace std; int main() { int n,k,q; cin>>n>>k>>q; multiset st; deque dq; auto Insert=[&](string str) { if (dq.size()>=n) { string fr=dq.front(); dq.pop_front(); st.erase(st.find(fr)); } dq.push_back(str); st.insert(str); }; while (q--) { int t; cin>>t; if (t==1) { string s; cin>>s; Insert(s); } else { int time=0; vector ins; for (int i=0;i<6;i++) { string s; int d; cin>>s>>d; time+=(st.count(s)?min(k,d):d); if (time<=60) { ins.push_back(s); } } cout<