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++: //#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n;
    cin >> n;
    vector<string> u(n);
    rep(i,n) cin>>u[i];
    int m;
    cin >> m;
    int f = 0;
    rep(i,m) {
        string s;
        cin >> s;
        auto it = find(ALL(u), s);
        if(it==u.end()) {
            cout << "Unknown " << s << endl;
        }
        else {
            if(f==0) {
                cout << "Opend by " << s << endl;
                f = 1;
            }
            else {
                cout << "Closed by " << s << endl;
                f = 0;
            }
        }
    }
    return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    string u;
    unordered_map<std::string, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> u;
        mp[u] = -1;
    }
    int m;
    cin >> m;
    string t[m];
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int key = -1;
    for (int i = 0; i < m; i++) {
        if (mp[t[i]]) {
            if (key == -1) {
                cout << "Opened by " << t[i];
                key = 1;
            } else {
                cout << "Closed by " << t[i];
                key = -1;
            }
        } else {
            cout << "Unknown " << t[i];
        }
        cout << endl;
    }

    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;j++)if(ic[j]==out)kawa=1;
		if(kawa)cout<<log[now]+out<<endl;
		else cout<<"Unknown "+out<<endl;
		now=(now+kawa)%2;
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n; scanf("%d", &n);
	vector<string>v;
	rep(i, n) {
		string s; cin >> s;
		v.push_back(s);
	}
	int m; scanf("%d", &m);
	bool b = false;
	rep(i, m) {
		string s; cin >> s;
		if (find(v.begin(), v.end(), s) == v.end())
			cout << "Unknown " << s << endl;
		else {
			if (b)cout << "Closed by " << s << endl;
			else cout << "Opend by " << s << endl;
			b = !b;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n;
	string u[n];
	for(int i=0;i<n;i++){
		cin >> u[i];
	}
	cin >> m;
	string t[m];
	int l=0;
	for(int i=0;i<m;i++){
		cin >> t[i];
		for(int j=0;j<n;j++){
			if((t[i]==u[j]) && (l%2==0)){
				cout << "Opened by " << t[i];
				l++;
				break;
			}else if((t[i]==u[j]) && (l%2==1)){
				cout << "Closed by " << t[i];
				l++;
				break;
			}
			if(j==n-1){
				cout << "Unknown " << t[i];
				break;
			}
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <string>

using namespace std;
 
bool flag;
 
bool check(string t, string u){
 if(s==t){
  if(!flag)cout << "Opened by " << t << endl;
  else cout << "Closed by " << t << endl;
  flag ^= 1;
  return true;
 }
 return false;
}
 
 
int main(){
 int n,i,j,m;
 bool ans=false;
 string u[260],t[260];
 cin >> n;
 for(i=0;i<n;i++)cin >> u[i];
 cin >> m;
 for(i=0;i<m;i++)cin >> t[i];
 for(i=0;i<m;i++){
  ans = false;
  for(j=0;j<n;j++)ans|=check(t[i],u[j]);
  if(!ans)cout << "Unknown " << t[i] << endl;
 }
 return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){

  int n;
  cin>>n;

  set <string> id;

  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    id.insert(s);
  }

  int m,open=0;
  cin>>m;

  for(int i=0;i<m;i++){

    string s;
    cin>>s;

    if(id.count(s)){ // if(id.find(s) != id.end()

      open++;

      if(open%2) cout<<"Opened by "+s<<endl;
      else cout<<"Closed by "+s<<endl;

    }

    else cout<<"Unknown "+s<<endl;

  }

  return 0;

}

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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int n, m;
	cin >> n;
	set<string> ss;
	REP(i,n){
		string s;
		cin >> s;
		ss.insert(s);
	}
	cin >> m;
	bool open = false;
	REP(i, m){
		string s;
		cin >> s;
		if (ss.find(s) == ss.end()){
			cout << "Unknown " << s << endl;
		}
		else{
			if (open){
				cout << "Closed by " << s << endl;
			}
			else{
				cout << "Opened by " << s << endl;
			}
			open ^= true;
		}
	}
}