#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>


template<typename Key, typename Value>
class TreapMapImpl {
	static std::mt19937_64 rand;
	Key _key;
	Value _value;
	decltype(rand()) _priority;
	TreapMapImpl* _left{ nullptr }, * _right{ nullptr };
	int _size = 1;
	TreapMapImpl* rotate_right() {
		auto left = _left;
		_left = _left->_right;
		left->_right = this;
		cal_new_size();
		left->cal_new_size();
		return left;
	}
	TreapMapImpl* rotate_left() {
		auto right = _right;
		_right = _right->_left;
		right->_left = this;
		cal_new_size();
		right->cal_new_size();
		return right;
	}
	void cal_new_size() {
		_size = 1;
		if (_left != nullptr) _size += _left->size();
		if (_right != nullptr) _size += _right->size();
	}
	TreapMapImpl* erase_this() {
		if (_left == nullptr && _right == nullptr) return nullptr;
		if (_left == nullptr) {
			auto res = _right;
			_right = nullptr;
			return res;
		}
		if (_right == nullptr) {
			auto res = _left;
			_left = nullptr;
			return res;
		}
		if (_left->_priority < _right->_priority) {
			auto res = rotate_left();
			res->_left = erase_this();
			res->cal_new_size();
			return res;
		}
		else {
			auto res = rotate_right();
			res->_right = erase_this();
			res->cal_new_size();
			return res;
		}
	}
public:
	TreapMapImpl(const Key& key, const Value& value) :_key{ key }, _value{ value }, _priority{ rand() }{};
	~TreapMapImpl() { delete _left, _right; };
	Key key() const { return _key; }
	Value value() const { return _value; }
	TreapMapImpl* find_by_rank(const int rank) {
		if (_left != nullptr && rank < _left->size()) {
			return _left->find_by_rank(rank);
		}
		else if ((_left != nullptr && rank == _left->size()) || (_left == nullptr && rank == 0)) {
			return this;
		}
		else {
			if (_left != nullptr) return _right->find_by_rank(rank - _left->size() - 1);
			else return _right->find_by_rank(rank - 1);
		}
	}
	int find_rank(const Key& key) const {
		if (key < _key) {
			if (_left == nullptr) return 0;
			return _left->find_rank(key);
		}
		else if (_key < key) {
			if (_right == nullptr) return size();
			if (_left == nullptr) return _right->find_rank(key) + 1;
			return _right->find_rank(key) + _left->size() + 1;
		}
		else {
			return (_left == nullptr) ? 0 : _left->size();
		}
	}
	std::pair<TreapMapImpl*, TreapMapImpl*> deleted(const Key& key) {
		if (_key < key) {
			if (_right == nullptr) return std::make_pair(this, nullptr);
			auto p = _right->deleted(key);
			_right = p.first;
			p.first = this;
			cal_new_size();
			return p;
		}
		else if (key < _key) {
			if (_left == nullptr) return std::make_pair(this, nullptr);
			auto p = _left->deleted(key);
			_left = p.first;
			p.first = this;
			cal_new_size();
			return p;
		}else return std::make_pair(erase_this(), this);
	}
	TreapMapImpl* inserted(const Key& key, const Value& value) {
		_size++;
		if (key < _key) {
			if (_left == nullptr) {
				_left = new TreapMapImpl(key, value);
			}
			else {
				_left = _left->inserted(key, value);
			}
			if (_left->_priority <= _priority) return this;
			else return rotate_right();
		}
		else {
			if (_right == nullptr) {
				_right = new TreapMapImpl(key, value);
			}
			else {
				_right = _right->inserted(key, value);
			}
			if (_right->_priority <= _priority) return this;
			else return rotate_left();
		}
	}
	int size() const { return _size; };
};
template<typename K, typename V>
std::mt19937_64 TreapMapImpl<K, V>::rand(0);

template<typename Key, typename Value>
class TreapMap {
	TreapMapImpl<Key, Value>* _tree = nullptr;
public:
	~TreapMap() { delete _tree; }
	void insert(const Key& key, const Value& value) {
		if (_tree == nullptr) {
			_tree = new TreapMapImpl<Key, Value>(key, value);
		}
		else {
			_tree = _tree->inserted(key, value);
		}
	}
	void erase(const Key& key) {
		if (_tree != nullptr) {
			auto res = _tree->deleted(key);
			delete res.second;
			_tree = res.first;
		}
	}
	int find_rank(const Key& key) {
		if (_tree == nullptr) return 0;
		else return _tree->find_rank(key);
	}
	std::pair<Key, Value> find_by_rank(const int rank) {
		auto res = _tree->find_by_rank(rank);
		return std::make_pair(res->key(), res->value());
	}
};

struct Rating {
	int rate, date;
	bool operator<(const Rating& that) const { return (rate == that.rate) ? date > that.date : rate > that.rate; }
};
int main() {
	TreapMap<Rating, std::string> set;
	std::map<std::string, Rating> menber;
	int n; std::cin >> n;
	for (auto d = 0; d < n; ++d) {
		std::string name; int rate; std::cin >> name >> rate;
		set.insert(Rating{ rate, d }, name);
		menber.insert(std::make_pair(name, Rating{ rate, d }));
	}
	int q; std::cin >> q;
	for (auto d = n; d < n + q; ++d) {
		std::string op, name; std::cin >> op >> name;
		if (op == "+") {
			int rate; std::cin >> rate;
			int current_worker = menber.size() / 5;
			set.insert(Rating{ rate, d }, name);
			menber.insert(std::make_pair(name, Rating{ rate, d }));
			if (set.find_rank(Rating{ rate, d }) < menber.size() / 5) {
				std::cout << name << " is working hard now.\n";
				if (current_worker == menber.size() / 5) {
					auto outer = set.find_by_rank(current_worker);
					std::cout << outer.second << " is not working now.\n";
				}
			}
			else {
				std::cout << name << " is not working now.\n";
				if (current_worker != menber.size() / 5) {
					auto inner = set.find_by_rank(current_worker);
					std::cout << inner.second << " is working hard now.\n";
				}
			}
		}
		else {
			int current_worker = menber.size() / 5;
			int current_rank = set.find_rank(menber[name]);
			set.erase(menber[name]);
			menber.erase(name);
			if (current_worker == menber.size() / 5 && current_rank < current_worker) {
				auto inner = set.find_by_rank(current_worker - 1);
				std::cout << inner.second << " is working hard now.\n";
			}
			else if (current_worker != menber.size() / 5 && current_rank >= current_worker) {
				auto outer = set.find_by_rank(current_worker - 1);
				std::cout << outer.second << " is not working now.\n";
			}
		}
	}
}


Measured memory_bytes: 11944