#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
using namespace std;
typedef pair<pair<int, int>, string> element;

template<typename T>
struct Multiset_Ex{
    map<T, int> memory;
    int total = 0;

    Multiset_Ex(){}
    void insert(const T &a){
        memory[a]++;
        total++;
    }
    bool erase(const T &a){
        if(memory.count(a) == 0) return false;
        memory[a]--;
        if(memory[a] == 0){
            memory.erase(a);
        }
        total--;
        return true;
    }
    int size(){
        return total;
    }
};

element change(element a){
    a.first.first = -a.first.first;
    a.first.second = -a.first.second;
    return a;
}
void print(string name, bool work){
    if(work){
        cout << name << " is working hard now." << endl;
    }else{
        cout << name << " is not working now." << endl;
    }
}
bool operator <(const element &a, const element &b){
    return a.first < b.first;
}

void pop_removed_element(priority_queue<element> &a, Multiset_Ex<element> &removed, bool high){
    while(!a.empty()){
        element key = (high)? change(a.top()): a.top();
        if(!removed.erase(key)) break;
        a.pop();
    }
}

int main(){
    int n;
    cin >> n;
    priority_queue<element> high, low;
    map<string, pair<int,int>> level;
    for(int i=0; i<n; i++){
        string name;
        int val;
        cin >> name >> val;
        level[name] = {val, i};
        low.push({{val, i}, name});
    }
    int high_size=n/5, low_size=n-n/5;
    for(int i=0; i<n/5; i++){
        element tmp = low.top();
        low.pop();
        high.push(change(tmp));
    }
    Multiset_Ex<element> removed;
    int m;
    cin >> m;
    for(int i=0; i<m; i++){
        string ch, name;
        cin >> ch >> name;
        if(ch == "+"){
            int val;
            cin >> val;
            element tmp = {{val, n+i}, name};
            // 追加処理
            level[name] = tmp.first;
            if((!high.empty() and change(high.top()) < tmp)
                    or (!low.empty() and low.top() < tmp and ((high_size +low_size +1) %5 == 0))){
                print(name, true);
                high.push(change(tmp));
                high_size++;
            }else{
                print(name, false);
                low.push(tmp);
                low_size++;
            }
        }else{
            // 削除処理
            element tmp = {level[name], name};
            removed.insert(tmp);
            if(high.empty() or tmp < change(high.top())){
                low_size--;
            }else{
                high_size--;
            }
        }
        // 境界移動
        pop_removed_element(high, removed, true);
        pop_removed_element(low, removed, false);
        if(high_size > (high_size + low_size)/5){
            print(high.top().second, false);
            low.push(change(high.top()));
            high.pop();
            high_size--;
            low_size++;
        }
        if(high_size < (high_size + low_size)/5){
            print(low.top().second, true);
            high.push(change(low.top()));
            low.pop();
            low_size--;
            high_size++;
        }
        pop_removed_element(high, removed, true);
        pop_removed_element(low, removed, false);
    }
    return 0;
}



Measured memory_bytes: 11776