#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=5e4+5;
struct node
{
    string s;
    int v,ti;
};
bool operator<(node a,node b)
{
    if(a.v==b.v) return a.ti>b.ti;
    return a.v>b.v;
}
set<node>s1,s2;
map<string,node>mp;
node a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,nn;
    node u;
    cin>>n;
    nn=floor(n/5.0);
    string opt;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].s>>a[i].v;
        a[i].ti=i;
        mp[a[i].s]=a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=nn;i++)
    {
        s1.insert(a[i]);
    }
    for(int i=nn+1;i<=n;i++)
    {
        s2.insert(a[i]);
    }
    cin>>m;
    int tn=n+m;
    for(int i=n+1;i<=tn;i++)
    {
        cin>>opt;
        if(opt[0]=='+')
        {
            cin>>u.s>>u.v; u.ti=i;
            mp[u.s]=u;
            n++;
            if(nn)
            {
                set<node>::iterator it=s1.end();it--;
                node p= *it;
                if(p.v<=u.v)
                {
                    s1.insert(u);
                    cout<<u.s<<" is working hard now."<<endl;
                    if(nn<floor(n/5.0)) nn++;
                    else
                    {
                        it=s1.end(); it--;
                        node e= *it;
                        cout<<e.s<<" is not working now."<<endl;
                        s1.erase(e);
                        s2.insert(e);
                    }
                }
                else
                {
                    s2.insert(u);
                    if(nn<floor(n/5.0))
                    {
                        nn++;
                        node e=*s2.begin();
                        if(e.s!=u.s)
                        {
                            cout<<u.s<<" is not working now."<<endl;
                        }
                        cout<<e.s<<" is working hard now."<<endl;

                        s2.erase(e);
                        s1.insert(e);
                    }
                    else
                    {
                        cout<<u.s<<" is not working now."<<endl;
                    }
                }

            }
            else
            {
                s2.insert(u);
                if(nn<floor(n/5.0))
                {
                    nn++;
                    node e=*s2.begin();
                    if(e.s==u.s)
                    {
                        cout<<e.s<<" is working hard now."<<endl;
                    }
                    else
                    {
                        cout<<u.s<<" is not working now."<<endl;
                        cout<<e.s<<" is working hard now."<<endl;
                    }
                    s2.erase(e);
                    s1.insert(e);
                }
                else
                {
                    cout<<u.s<<" is not working now."<<endl;
                }
            }
        }
        else
        {
            n--;
            cin>>opt;
            node u=mp[opt];
            if(s1.erase(u))
            {
                //cout<<u.s<<" is not working now."<<endl;
                if(nn==floor(n/5.0))
                {
                    node e=*s2.begin();
                    cout<<e.s<<" is working hard now."<<endl;
                    s2.erase(e);
                    s1.insert(e);
                }
                else nn--;
            }
            else
            {
                //cout<<u.s<<" is not working now."<<endl;
                s2.erase(u);
                if(nn>floor(n/5.0))
                {
                    nn--;
                    set<node>::iterator it=s1.end(); it--;
                    node e= *it;
                    cout<<e.s<<" is not working now."<<endl;
                    s1.erase(e);
                    s2.insert(e);
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 13440