#include <iostream>
#include <vector>
#include<algorithm>
#include <math.h>
#include <iomanip>
#include <stack>
#include <string>
#include <set>
#include <map>
using namespace std;
int sz,q;
int tables[(int)1e5+1],freq[(int)1e5+1];
set<int>f_availble[(int)1e5+1];
set<int>dis_sizes;
int main(){
cin>>sz>>q;
for (int i=0; i<sz; i++) {
cin>>tables[i];
dis_sizes.insert(tables[i]);
freq[tables[i]]++;
f_availble[tables[i]].insert(i+1);
}
set<int>::iterator myit,t;
for (int i=0; i<q; i++) {
string what;
int n;
cin>>what>>n;
if (what=="in") {
myit = dis_sizes.lower_bound(n);
if (myit==dis_sizes.end()) {
cout<<"-1"<<endl;
}
else{
freq[*myit]--;
if (freq[*myit]==0) {
dis_sizes.erase(myit);
}
cout<<*(f_availble[*myit].begin())<<endl;
f_availble[*myit].erase(f_availble[*myit].begin());
}
}
else{
dis_sizes.insert(tables[n-1]);
freq[tables[n-1]]++;
f_availble[tables[n-1]].insert(n);
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlIDxtYXRoLmg+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBzeixxOwppbnQgdGFibGVzWyhpbnQpMWU1KzFdLGZyZXFbKGludCkxZTUrMV07CnNldDxpbnQ+Zl9hdmFpbGJsZVsoaW50KTFlNSsxXTsKc2V0PGludD5kaXNfc2l6ZXM7CmludCBtYWluKCl7CiAgICBjaW4+PnN6Pj5xOwogICAgZm9yIChpbnQgaT0wOyBpPHN6OyBpKyspIHsKICAgICAgICBjaW4+PnRhYmxlc1tpXTsKICAgICAgICBkaXNfc2l6ZXMuaW5zZXJ0KHRhYmxlc1tpXSk7CiAgICAgICAgZnJlcVt0YWJsZXNbaV1dKys7CiAgICAgICAgZl9hdmFpbGJsZVt0YWJsZXNbaV1dLmluc2VydChpKzEpOwogICAgfQogICAgc2V0PGludD46Oml0ZXJhdG9yIG15aXQsdDsKICAgIGZvciAoaW50IGk9MDsgaTxxOyBpKyspIHsKICAgICAgICBzdHJpbmcgd2hhdDsKICAgICAgICBpbnQgbjsKICAgICAgICBjaW4+PndoYXQ+Pm47CiAgICAgICAgaWYgKHdoYXQ9PSJpbiIpIHsKICAgICAgICAgICAgbXlpdCA9IGRpc19zaXplcy5sb3dlcl9ib3VuZChuKTsKICAgICAgICAgICAgaWYgKG15aXQ9PWRpc19zaXplcy5lbmQoKSkgewogICAgICAgICAgICAgICAgY291dDw8Ii0xIjw8ZW5kbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgZnJlcVsqbXlpdF0tLTsKICAgICAgICAgICAgICAgIGlmIChmcmVxWypteWl0XT09MCkgewogICAgICAgICAgICAgICAgICAgIGRpc19zaXplcy5lcmFzZShteWl0KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvdXQ8PCooZl9hdmFpbGJsZVsqbXlpdF0uYmVnaW4oKSk8PGVuZGw7CiAgICAgICAgICAgICAgICBmX2F2YWlsYmxlWypteWl0XS5lcmFzZShmX2F2YWlsYmxlWypteWl0XS5iZWdpbigpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBkaXNfc2l6ZXMuaW5zZXJ0KHRhYmxlc1tuLTFdKTsKICAgICAgICAgICAgZnJlcVt0YWJsZXNbbi0xXV0rKzsKICAgICAgICAgICAgZl9hdmFpbGJsZVt0YWJsZXNbbi0xXV0uaW5zZXJ0KG4pOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9