Go: package main

import "fmt"

func main() {
    var n, m int
    fmt.Scan(&n)

    u := make([]string, 300)

    for i := 0; i < n; i++ {
        fmt.Scan(&u[i])
    }

    fmt.Scan(&m)

    is_lock := true
    for i := 0; i < m; i++ {
        var t string
        fmt.Scan(&t)

        is_include := false
        for j := 0; j < n; j++ {
            if t == u[j] {
                is_include = true
                break
            }
        }
        if is_include == false {
            fmt.Printf("Unknown %s\n", t)
        } else if (is_lock) {
            fmt.Printf("Opened by %s\n", t)
            is_lock = false
        } else {
            fmt.Printf("Closed by %s\n", t)
            is_lock = true
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int solve() {
    int N, M;
    bool flag = false;
    vector<string> ids;
    cin >> N;
    for(int i=0; i<N; i++) {
        string s;
        cin>>s;
        ids.push_back(s);
    }

    cin >> M;
    for(int i=0; i<M; i++) {
        string s;
        cin >> s;
        auto result = find(ids.begin(), ids.end(), s);
        if(result == ids.end()) {
            cout << "Unknown " << s << endl;
        } else {
            flag = !flag;
            if(flag) cout << "Opened by " << *result << endl;
            else cout << "Closed by " << *result << endl;
        }
    }
    return 0;
}

int main() {
    return solve();
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve() {
    int N; cin >> N;
    set<string> se;
    REP(i, N) {
        string s; cin >> s;
        se.insert(s);
    }
    int M; cin >> M;
    bool now = false;
    REP(i, M) {
        string s; cin >> s;
        string ans = "";
        if (!FIND(se, s)) {
            ans = "Unknown ";
        } else {
            if (now) ans = "Closed by ";
            else ans = "Opened by ";
            now = !now;
        }
        cout<< ans << s << endl;
    }
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z;
    string s;
    while (true) {
        solve();
        return 0;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,now=0;
	string ic[257]={""},out,log[2]={"Opened by ","Closed by "};
	for(cin>>n;n>0;n--)cin>>ic[n];
	for(cin>>m;m>0;m--){
		bool kawa=0;
		cin>>out;
		for(int j=1;j<255&&!kawa;j++)if(ic[j]==out)kawa=1;
		if(kawa)cout<<log[now]+out<<endl;
		else cout<<"Unknown "+out<<endl;
		now=(now+kawa)%2;
	}
}

C++: // 2016-11-30
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n, m;
	string u[256], t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u[i];
	}
	cin >> m;
	bool o = false;
	for (int i = 0; i < m; i++) {
		cin >> t;
		int j;
		for (j = 0; j < n; j++) {
			if (t == u[j]) {
				cout << (o ? "Closed by " : "Opened by ") << t << endl;
				o ^= true;
				break;
			}
		}
		if (j == n) {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int main(){
  set<string> keys;

  int n,m;
  cin >> n;

  rep(i,n){
    char s[12];
    scanf("%s", s);
    string key(s);
    keys.insert(key);
  }

  cin >> m;

  bool door=false;
  rep(i,m){
    char s[12];
    scanf("%s", s);
    string key(s);
    if( keys.find(key) != keys.end() ){ //find
      if(!door)
	cout << "Opened by " << key << endl;
      else
	cout << "Closed by " << key << endl;
      door = !door;

    }else {
      cout << "Unknown " << key << endl;

    }
  }

}

C++: // #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<string> U(N);
    for(int i=0; i<N; i++) cin >> U[i];
    int M; scanf("%d", &M);
    vector<string> T(M);
    for(int i=0; i<M; i++) cin >> T[i];

    bool open = false;
    for(int i=0; i<M; i++) {
        auto ptr = find(U.begin(), U.end(), T[i]);
        if(ptr == U.end()) {
            printf("Unknown %s\n", T[i].c_str());
        }
        else {
            open ^= true;
            if(open) {
                printf("Opened by %s\n", T[i].c_str());
            }
            else {
                printf("Closed by %s\n", T[i].c_str());
            }
        }
    }
    
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res=0;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

set<string> st;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    st.insert(s);
  }
  int m;
  cin>>m;
  bool op=false;
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    if(st.count(s)>0){
      if(!op)cout<<"Opened by ";
      else cout<<"Closed by ";
      op^=1;
    }
    else
      cout<<"Unknown ";
    cout<<s<<endl;
  }
  return 0;
}