#include #include #include using namespace std; struct oseba{ string ime, priimek; int vrsta; }oseba[101]; deque vrsta[101]; bool counter[101]; int main(){ deque::reverse_iterator it; int N, M, T; int mode, k; string s; cin>>N>>M; for(int i=0; i<101; i++) counter[i] = false; for(int i=0; i>oseba[i].ime>>oseba[i].priimek; oseba[i].vrsta = -1; } cin>>T; for(int i=0; i>mode; if(mode == 1){ cin>>k; counter[k] = !counter[k]; if(counter[k] == false){ it = vrsta[k].rbegin(); while(it != vrsta[k].rend()){ mode = *it; oseba[mode].vrsta = -1; it++; } vrsta[k].clear(); } } else if(mode == 2){ cin>>mode>>s; for(int x=0; x>k; mode = *(vrsta[k].begin()); oseba[mode].vrsta = -1; vrsta[k].pop_front(); } else if(mode == 4){ cin>>k; if(vrsta[k].empty()){ cout<<-1<<'\n'; } else{ it = vrsta[k].rbegin(); while(it != vrsta[k].rend()){ cout<>s; for(int y = 0; y