#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <set>
#include <unordered_map>
#define inputt int t;cin>>t;
#define pi acos(-1.0)
#define lson o*2,l,m
#define rson o*2+1,m+1,r
#define INF 0x7f7f7f7f
#define lowbit(X) ((X)&(-X))
#define clr(X,Y) memset(X,Y,sizeof(X))
typedef long long ll;
using namespace std;

struct node{
	char s[25];
	int val;
	int time;
}a[70005];


struct cmp1{
	bool operator() (const node &a,const node b)const{
		return a.val<b.val||a.val==b.val&&a.time<b.time;
	}
};
struct cmp2{
	bool operator() (const node &a,const node b)const{
		return a.val>b.val||a.val==b.val&&a.time>b.time;
	}
};
unordered_map<string,int>mp;
set<node,cmp1>maxheap;
set<node,cmp2>minheap;
set<node,cmp1>::iterator it1;
set<node,cmp2>::iterator it2;
void print(){
	printf("-------------\n");
	printf("max\n");
	for(it2=minheap.begin();it2!=minheap.end();it2++){
		node p=*it2;
		printf("%s %d %d\n",p.s,p.val,p.time);
	}
	printf("min\n");
	for(it1=maxheap.begin();it1!=maxheap.end();it1++){
		node p=*it1;
		printf("%s %d %d\n",p.s,p.val,p.time);
	}
	printf("-------------\n");
}
int main(){
	int n;
	scanf("%d",&n);
	int now=n;
	for(int i=0;i<n;i++){
		scanf("%s%d",a[i].s,&a[i].val);
		mp[a[i].s]=i;
		a[i].time=i;
		minheap.insert(a[i]);
		if(minheap.size()>n*0.2){
			it2=minheap.end();
			it2--;
			maxheap.insert(*it2);		
			minheap.erase(it2);
		}
	}
	//print();
	int m;
	char op[2];
	char ts[25];
	scanf("%d",&m);
	for(int i=n;i<n+m;i++){
		scanf("%s",op);
		if(op[0]=='+'){
			scanf("%s%d",a[i].s,&a[i].val);
			a[i].time=i;
			mp[a[i].s]=i;
			if(int((now+1)*0.2)-int(now*0.2)==0){
				minheap.insert(a[i]);
				if(minheap.size()>int((now+1)*0.2)){
					it2=minheap.end();
					it2--;
					if((*it2).time==a[i].time){
						printf("%s is not working now.\n",a[i].s);
						maxheap.insert(*it2);
						minheap.erase(it2);
					}
					else{
						printf("%s is working hard now.\n%s is not working now.\n",a[i].s,(*it2).s);
						maxheap.insert(*it2);
						minheap.erase(it2);
					}
				}
			}
			else{
				it1=maxheap.end();
				it1--;
				if((*it1).val>a[i].val){
					printf("%s is not working now.\n%s is working hard now.\n",a[i].s,(*it1).s);
					minheap.insert((*it1));
					maxheap.erase(it1);
					maxheap.insert(a[i]);
				}
				else {
					printf("%s is working hard now.\n",a[i].s);
					minheap.insert(a[i]);
				}
			}
			now++;
		}
		else {
			scanf("%s",ts);
			int idx=mp[ts];
			if(int(now*0.2)-int((now-1)*0.2)==0){    //???????? working??????±? 
				if(minheap.find(a[idx])!=minheap.end()){
					minheap.erase(a[idx]);
					it1=maxheap.end();
					it1--;
					minheap.insert(*it1);
					printf("%s is working hard now.\n",(*it1).s);
					maxheap.erase(it1);
				}
				else if(maxheap.find(a[idx])!=maxheap.end()){
					maxheap.erase(a[idx]);
				}
			}
			else{                                     //???????? 
				if(minheap.find(a[idx])!=minheap.end()){  // ??working??????£¬?±???????´?? 
					minheap.erase(a[idx]);
				}
				else if(maxheap.find(a[idx])!=maxheap.end()){   //??not working??????£¬?????¢´?work??????????not working 
					maxheap.erase(a[idx]);
					it2=minheap.end();
					it2--;
					maxheap.insert(*it2);
					printf("%s is not working now.\n",(*it2).s);
					minheap.erase(it2);
				}
			}
			now--;
		}
		//print();
	}
	return 0;
}

Measured memory_bytes: 15232