function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);
    var k = 1;

    var u = [];
    for(var i = 0;i < n;i++){
        u[i] = input[k++];
    }

    var m = parseInt(input[k++],10);var st = 1;
    for(var i = 0;i < m;i++){
        var t = input[k++];var flag = true;
        for(var j = 0;j < n;j++){
            if(t == u[j]){
                if(st == 1)
                    console.log("Opened by " + t);
                else
                    console.log("Closed by " + t);
                st *= -1;
                flag = false;
                break;
            }
        }
        if(flag)
            console.log("Unknown " + t);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));