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>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int N;cin >> N;
    map<string,bool> mp;
    for(int a = 0;a < N;a++){
        string s;cin >> s;
        mp[s] = 1;
    }
    int M;cin >> M;
    bool kagi = false;
    for(int i = 0;i < M;i++){
        string s;cin >> s;
        if(mp[s] != 1){
            cout<<"Unknown "<<s<<endl;
            continue;
        }
        if(!kagi){
            cout<<"Opened by "<<s<<endl;
            kagi = !kagi;
        }else{
            cout<<"Closed by "<<s<<endl;
            kagi = !kagi;
        }
    }
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	int n, m;
	map<string, int> id;
	cin >> n;
	for(int i=0; i<n; i++){
		string t;
		cin >> t;
		id[t] = 1;
	}
	cin >> m;
	int state = 1;
	for(int i=0; i<m; i++){
		string t;
		cin >> t;
		if(id.find(t) == id.end()){
			cout << "Unknown " << t << endl;
		}else if(state == 1){
			cout << "Opened by " << t << endl;
			state = 0;
		}else if(state == 0){
			cout << "Closed by " << t << endl;
			state = 1;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;

int main(){
	int n,m;
	vector<string> u;
	cin >> n;
	for(int i=0;i<n;i++){
		string U;
		cin >> U;
		u.push_back(U);
	}
	cin >> m;
	int ans=0;
	for(int i=0;i<m;i++){
		string T;
		cin >> T;
		int judge=0;
		for(int j=0;j<u.size();j++){
			if(T==u[j]){
				ans++;
				judge++;
			}
		}
		if(judge==0) cout << "Unknown " << T << endl;
		else if(ans%2==1) cout << "Opened by " << T << endl;
		else if(ans%2==0&&judge!=0) cout << "Closed by " << T << endl;
	}

}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int i,j,k,l;
	int n,m;
	char a[257][257];
	char b[257][257];
	int p=0; //空いていれば１

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{scanf("%s",a[i]);}

	scanf("%d",&m);
	for(i=0;i<m;i++)
	{scanf("%s",b[i]);}

	for(i=0;i<m;i++)
		{
			int c=0; 
			for(j=0;j<n;j++)
			{
				if(strcmp(b[i],a[j])==0)
				{
					if(p==0){printf("Opened by %s\n",b[i]);p=1;c++;break;}
					else{printf("Closed by %s\n",b[i]);p=0;c++;break;}
				}
			}
			if(c==0)
			{
				printf("Unknown %s\n",b[i]);
			}
		}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;
    set<string> st;
    REP(i,n){
        string s; cin>>s;
        st.insert(s);
    }
    
    int m; cin>>m;
    bool locked=true;
    REP(i,m){
        string s; cin>>s;
        if(st.count(s)){
            locked=!locked;
            cout<<(locked?"Closed ":"Opened ");
        } else{
            cout<<"Unknown ";
        }
        cout<<s<<endl;
    }
        
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;

vector<string> usr_name;

int main(){
  vector<string>::iterator it;
  int n,m,i = 0,j = 0;
  bool k = 0;
  string tmp;
  cin >>n;
  cin.ignore();
  for(i = 0;i < n;i++){
    cin >>tmp;
    usr_name.push_back(tmp);
    cin.ignore();
  }
  cin >> m;
  cin.ignore();
  for(i = 0; i<m;i++){
    j = 0;
    cin >> tmp;
    it = usr_name.begin();
    while(it != usr_name.end()){
      it++;
      if(tmp == usr_name[j]){
	if(k == 0){
	  cout << "Opened by "<<tmp<<endl;
	  k = !k;
	}else{
	  cout << "Closed by "<<tmp<<endl;
	  k = !k;
	}
	j = -1;
	break;
      }
      j++;
    }
    if(j != -1)
      cout <<"Unknown "<<tmp<<endl;
  }
    return 0;
  }

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 << "Opened by " << s << endl;
                f = 1;
            }
            else {
                cout << "Closed by " << s << endl;
                f = 0;
            }
        }
    }
    return 0;
}