#include <functional>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

class entity{
	static const char* colorArray[];
	size_t _index;
	int _time;
public:
	entity(int time) : _index(0U), _time(time) {}
	void AddRed() {_index |= 4U;}
	void AddYellow() {_index |= 2U;}
	void AddBlue() {_index |= 1U;}
	auto GetInitializedTime() const {return _time;}
	auto Result() const {return colorArray[_index];}
};

const char* entity::colorArray[] = {"black", "blue", "yellow", "green", "red", "purple", "orange", "white"};

int main() {
	map<int, function<void(entity&)>> events = {{3, mem_fn(&entity::AddRed)}, {9, mem_fn(&entity::AddBlue)}, {11, mem_fn(&entity::AddYellow)}};
	vector<entity> Entity = {entity(1), entity(8), entity(13)};
	
	for(auto& i : Entity) {
		for(auto j = events.upper_bound(i.GetInitializedTime()); j != events.end(); ++j) {
			j->second(i);
		}
		cout << i.Result() << endl;
	}
	
	return 0;
}