#include <bits/stdc++.h>
using namespace std ;

set < pair < pair < int, int >, string > > Q,FQ ;
map < string,int > val, id ;
int n ;
string s, type ;
int x, q ;
int main()
{
    scanf("%d",&n ) ;

    for( int i = 1 ; i <= n ; i++ )
    {
        cin >> s >> x ;
        FQ.insert(make_pair(make_pair(x,i),s ) ) ;
        val[s] = x ;
        id[s] = i ;
    }

    int r, nr ;
    r = n / 5 ;
    pair < pair < int, int >, string > yo ;
    for( int i = 0 ; i < r ; i++ )
    {
        yo = *--FQ.end() ;
       //  cout <<yo.first.first <<" " <<yo.first.second << " " << yo.second << endl ;
        Q.insert(yo) ;
        FQ.erase(--FQ.end()) ;
    }

    scanf("%d",&q ) ;
    int iid = n +1;
    for( int i = 0 ; i < q ; i++,iid++ )
    {
        cin >> type >> s  ;
        if(type == "+" )
        {
            cin>> x ;
            id[s] = iid ;
            val[s] = x ;

            n++ ;
			nr = n / 5 ;

            if( nr == 0 )
            {
                cout << s <<" is not working now." << endl ;
                FQ.insert(make_pair(make_pair(x,iid), s ) ) ;
            }
            else if( r == nr )
            {
                yo = *Q.begin() ;
                if(yo.first.first  > x )
                {
                    cout << s <<" is not working now." << endl ;
                    FQ.insert(make_pair(make_pair(x,iid), s ) ) ;
                }
                else
                {
                    cout << s <<" is working hard now." << endl ;
                    cout << yo.second <<" is not working now." << endl ;
                    Q.erase(Q.begin()) ;
                    Q.insert(make_pair(make_pair(x,iid), s ) ) ;
                    FQ.insert(yo) ;
                }
            }
            else
            {
                yo = *--FQ.end() ;
                if(yo.first.first  > x )
                {
                    cout << s <<" is not working now." << endl ;
                    cout << yo.second <<" is working hard now." << endl ;
                    FQ.erase(--FQ.end()) ;
                    FQ.insert(make_pair(make_pair(x,iid), s ) ) ;
                    Q.insert(yo) ;
                }
                else
                {
                    cout << s <<" is working hard now." << endl ;
                    Q.insert(make_pair(make_pair(x,iid), s ) ) ;
                }

            }
            r = nr ;

        }

        else
        {
            int hisID = id[s] ;
            x = val[s] ;
            n-- ;

			nr = n/5 ;
			//cout << hisID << " " << x << " " << nr << " " << s << endl ;
            if( r == 0 ) continue ;
            else if( r == nr )
            {
                if( Q.find(make_pair(make_pair(x,hisID), s )) != Q.end() )
                {
                   // cout << s <<" is not working now." << endl ;
                    Q.erase(Q.find(make_pair(make_pair(x,hisID), s ))) ;
                    yo = *--FQ.end() ;
                    cout << yo.second <<" is working hard now." << endl ;
                    Q.insert(yo) ;
                    FQ.erase(--FQ.end()) ;
                }
                else
				{
					 FQ.erase(FQ.find(make_pair(make_pair(x,hisID), s ))) ;
				}
            }
            else
            {
            	//cout << x << " " << hisID << " " << s << endl ;
            	 yo = *Q.begin() ;
            	// cout <<yo.first.first <<" " <<yo.first.second << " " << yo.second << endl ;
                if( Q.find(make_pair(make_pair(x,hisID), s )) != Q.end() )
                {
                	//cout<< "sgfkdflgadfg" << endl ;
                    //cout << s <<" is not working now." << endl ;
                    Q.erase(Q.find(make_pair(make_pair(x,hisID), s ))) ;
                }

                else
                {
                    yo = *Q.begin() ;
                    cout << yo.second <<" is not working now." << endl ;
                    Q.erase(Q.begin()) ;
                    FQ.insert(yo) ;
					FQ.erase(FQ.find(make_pair(make_pair(x,hisID), s ))) ;

                }

            }
            r = nr ;
        }
    }


    return 0 ;
}

/*
5
a 5
b 1
c 4
d 3
e 5
100
- e

*/

Measured memory_bytes: 16412