#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define maxn 100005
#define ll unsigned long long

struct node{
    string name;
    int val;
    int t;
    bool operator<(const node& s) const {
        return val==s.val?t<s.t:val<s.val;
    }
    bool operator>(const node& s) const {
        return val==s.val?t>s.t:val>s.val;
    }
    bool operator ==(const node& s) const{
        return name==s.name;
    }
};

set<node> Q1;
set<node,greater<node> > Q2;

node v[maxn];
int up;
map<string,int> ms;
map<string,int> mt;

int main(){
//    freopen("ou.txt","w",stdout);
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
            cin>>v[i].name;
            cin>>v[i].val;
            v[i].t=i;
            ms[v[i].name]=v[i].val;
            mt[v[i].name]=i;
    }
    sort(v,v+n,greater<node>());
    int la=up=n*0.20;
    int time=n;
    for(int i=0;i<up;i++){
        Q1.insert(v[i]);
    }
    for(int i=up;i<n;i++){
        Q2.insert(v[i]);
    }

    int m;
    cin>>m;
    while(m--){
        time++;
        char c;
        node x;
        cin>>c>>x.name;
        x.t=time;
        if(c=='+'){
            cin>>x.val;
            ms[x.name]=x.val;
            mt[x.name]=time;
            n++;
            up=n*0.20;
 //          cout<<la<<' '<<up<<endl;
            if(up>la){
                if(Q2.size()&&x<(*Q2.begin())) {
                    node top=*Q2.begin();
                    Q1.insert(top);
                    cout<<x.name<<" is not working now.\n";
                    cout<<top.name<<" is working hard now.\n";
                    Q2.erase(top);
                    Q2.insert(x);
                }else {
                    Q1.insert(x);
                    cout<<x.name<<" is working hard now.\n";
                }
            }else{
       //         cout<<x.name<<endl;
                if(!Q1.empty()&&((*Q1.begin())<x)){
                    node top=*Q1.begin();
                    Q2.insert(top);
                    cout<<x.name<<" is working hard now.\n";
                    cout<<top.name<<" is not working now.\n";
                    Q1.erase(top);
                    Q1.insert(x);
                }else{
                    Q2.insert(x);
                    cout<<x.name<<" is not working now.\n";
                }
            }
            la=up;
        }else{
            n--;
            up=n*0.20;
 //           cout<<la<<' '<<up<<endl;
            x.val=ms[x.name];
            x.t=mt[x.name];
 //           cout<<"Q1.size()= "<<Q1.size()<<endl;
            if(up<la){
                    if(Q1.count(x)){
                        Q1.erase(x);
                    }else{
                        Q2.erase(x);
                        if(Q1.empty()) continue;
                        node top=*Q1.begin();
                        cout<<top.name<<" is not working now.\n";
                        Q1.erase(top);
                        Q2.insert(top);
                    }
            }else{
      //          cout<<"-----"<<x.name<<endl;
                if(Q1.count(x)){
                    Q1.erase(x);
                    node top=*Q2.begin();
                    cout<<top.name<<" is working hard now.\n";
                    Q2.erase(top);
                    Q1.insert(top);
                }else{
                    Q2.erase(x);
                }
            }
            la=up;
        }
    }
    return 0;
}

Measured memory_bytes: 17740