import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	auto n = readln.chomp.to!int;
	bool[string] ids;
	foreach (i; 0..n) {
		auto x = readln.chomp;
		ids[x] = 1;
	}
	auto m = readln.chomp.to!int;
	bool s;
	foreach (i; 0..m) {
		auto x = readln.chomp;
		if (ids.get(x, 0)) {
			if (s) writeln("Closed by ", x);
			else  writeln("Opened by ", x);
			s = !s;
		} else {
			writeln("Unknown ", x);
		}
	}
}