#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	IN,
	OUT,
};

struct Info{
	Info(string arg_name,int arg_value,int arg_input_index,int arg_in_query){
		name = arg_name;
		value = arg_value;
		input_index = arg_input_index;
		in_query = arg_in_query;
		out_query = BIG_NUM;
	}
	bool operator<(const struct Info &arg) const{
		if(value != arg.value){
			return value < arg.value; //モチベーションが違うなら、その昇順
		}else{
			return input_index < arg.input_index; //モチベーションが同じなら、加入番の昇順
		}
	}
	string name;
	int value,input_index,in_query,out_query;
};

struct Data{
	Type type;
	int index;
};

int N;
int BIT[80000];
map<string,int> MAP;
vector<Info> V;
Data query[20000];

void add(int loc,int value){

	BIT[loc] += value;

	loc += loc & -loc; //最後の1ビットを足した場所が次の★更新★場所

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

int getSum(int loc){

	int sum = BIT[loc];

	loc -= loc & -loc; //最後の1ビットを引いた場所が次の★加算★場所

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

int calc(int left,int right){ //left～rightの区間の総和を、sum(1～right)-sum(1～left-1)で求める
	return getSum(right)-getSum(left-1);
}

int main(){

	int index = 0;

	//初期メンバーを登録
	int first_N;
	scanf("%d",&first_N);

	string name;
	int value;

	for(int i = 0; i < first_N; i++){
		cin >> name >> value;
		V.push_back(Info(name,value,i,-1));
		MAP[name] = i; //vectorのインデックスを入力
		index++;
	}

	//クエリを入力
	int num_query;
	scanf("%d",&num_query);

	char buf[2];

	for(int i = 0; i < num_query; i++){
		scanf("%s",buf);

		if(buf[0] == '+'){
			query[i].type = IN;
			cin >> name >> value;
			V.push_back(Info(name,value,index,i)); //ノードが有効になるクエリのインデックスを記録
			MAP[name] = index;
			index++;

		}else{
			query[i].type = OUT;
			cin >> name;
			V[MAP[name]].out_query = i; //ノードが無効になるクエリのインデックスを記録
		}
	}

	sort(V.begin(),V.end());

	N = index;
	for(int i = 0; i <= N; i++)BIT[i] = 0; //BIT木は1インデックス!!!

	//初期メンバーに1を立てる、およびクエリをO(1)で処理するための準備
	for(int i = 0; i < index; i++){
		if(V[i].in_query == -1){ //初期メンバー
			add(i+1,1); //★★BIT木は1インデックス!!★★
		}else{
			query[V[i].in_query].index = i;
		}
		if(V[i].out_query == BIG_NUM)continue;
		query[V[i].out_query].index = i;
	}

	int member_num = first_N,work_num,pre_work_num = first_N/5;
	int tmp_index,tmp_rank,changed_index,del_rank;

	int left,right,m;

	for(int i = 0; i < num_query; i++){

		if(query[i].type == IN){

			tmp_index = query[i].index+1;
			add(tmp_index,1);

			member_num++;
			work_num = member_num/5;

			//新メンバーの順位を取得
			tmp_rank = calc(tmp_index,N);

			if(tmp_rank <= work_num){ //上位2割りに入った場合
				printf("%s is working hard now.\n",V[tmp_index-1].name.c_str());
			}else{
				printf("%s is not working now.\n",V[tmp_index-1].name.c_str());
			}

			//他のメンバーの変化を調べる
			if(pre_work_num == work_num){ //上位2割の人数に変化なし

				if(tmp_rank > work_num){ //新メンバーが上位2割でない
					//変化なし
				}else{
					//work_num+1位の人物が、yes→notに変化したはず

					//2分探索で、work_num+1位の人物を探索
					left = 1,right = N,m = (left+right)/2;
					while(left <= right){
						if(calc(m,N) >= work_num+1){
							changed_index = m;
							left = m+1; //★★より右へ★★
						}else{
							right = m-1;
						}
						m = (left+right)/2;
					}

					printf("%s is not working now.\n",V[changed_index-1].name.c_str());
				}

			}else{ //上位2割の人数が1増えた場合

				if(tmp_rank <= work_num){ //新メンバーが上位2割
					//変化なし
				}else{
					//work_num位の人物が、not→yesに変化したはず

					left = 1,right = N,m = (left+right)/2;
					while(left <= right){
						if(calc(m,N) >= work_num){
							changed_index = m;
							left = m+1;
						}else{
							right = m-1;
						}
						m = (left+right)/2;
					}

					printf("%s is working hard now.\n",V[changed_index-1].name.c_str());
				}
			}

		}else{ //OUT処理

			tmp_index = query[i].index+1;
			del_rank = calc(tmp_index,N); //OUTする人の順位を取得
			add(tmp_index,-1);

			member_num--;
			work_num = member_num/5;

			if(work_num == pre_work_num){ //上位2割の人数が変わらない場合

				if(del_rank > work_num){ //消えた人が元々notだった場合
					//変化なし

				}else{
					//work_num位の人物が、no→yesに変化したはず
					left = 1,right = N,m = (left+right)/2;
					while(left <= right){
						if(calc(m,N) >= work_num){
							changed_index = m;
							left = m+1;
						}else{
							right = m-1;
						}
						m = (left+right)/2;
					}

					printf("%s is working hard now.\n",V[changed_index-1].name.c_str());
				}

			}else{ //上位2割の人数が1減る場合

				if(del_rank <= pre_work_num){ //消えた人以外にyesがtmp_work_num人いた場合
					//変化なし
				}else{
					//pre_work_num位の人物が、yes→notに変化するはず

					//2分探索で、pre_work_num位の人物を探索
					left = 1,right = N,m = (left+right)/2;
					while(left <= right){
						if(calc(m,N) >= pre_work_num){
							changed_index = m;
							left = m+1;
						}else{
							right = m-1;
						}
						m = (left+right)/2;
					}
					printf("%s is not working now.\n",V[changed_index-1].name.c_str());
				}
			}
		}
		pre_work_num = work_num;
	}

	return 0;
}



Measured memory_bytes: 11224