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>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;

int main() {
  int N, M, key = 0, kk = 0;
  string U[256], T;
  cin >> N;
  rep(i, N) cin >> U[i];
  cin >> M;
  rep(i, M) {
    cin >> T;
    rep(i, N) {
      if (U[i] == T && key == 0) {
        cout << "Opened by " << T << endl;
        key = 1;
        kk = 1;
        break;
      } else if (U[i] == T && key == 1) {
        cout << "Closed by " << T << endl;
        key = 0;
        kk = 1;
        break;
      }
    }
    if (kk == 0) {
      cout << "Unknown " << T << endl;
    }
    kk = 0;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#include<unistd.h>

using namespace std;
int main() {
        vector<string>VS{ "Opened by ","Closed by ","Unknown " };
        set<string>SS;
        int N;
        cin >> N;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                SS.insert( S );
        }
        sleep(2);
        cin >> N;
        bool x = 0;
        for( size_t i = 0; i < N; i++ ) {
                string S;
                cin >> S;
                if( SS.end() == find( SS.begin(), SS.end(), S ) ) {
                        cout << VS[2] << S << endl;
                } else {
                        cout << VS[x] << S << endl;
                        x = 1 - x;
                }
        }
        return 0;
}

C++: #if 0
#include <bits/stdc++.h>
#else
#include "../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N, M;
char U[258][12], T[258][12];

void input(){
  cin>>N;
  REP(i, N)cin>>U[i];
  cin>>M;
    REP(i, M)cin>>T[i];
}

void solve(){
  bool d=true;
  REP(i, M) {
    bool c = false;
    REP(j, N) {
      c = [](int x, int y) {
        int k;
        if(U[x][0]!=T[y][0])return false;
        for(k=1;U[x][k-1]!='\0';k++) {
          if(U[x][k]!=T[y][k])return false;
        }
        return true;
      }(j, i);
      if(c) {
        if(d)cout<<"Opened by "<<T[i];
        else cout<<"Closed by "<<T[i];
        d = !d;
        break;
      }
    }
    if(!c)cout<<"Unknown "<<T[i];
    cout<<endl;
  }
}

int main(){
  cin.tie(0);

  input();
  solve();

  return 0;
}

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

using namespace std;

int main(){
	int N,M;
	scanf("%d",&N);
	int flag=0,oc=0,i,j;
	char U[256][11];
	for(i=0;i<N;i++){
		scanf("%s",U[i]);
	}
	scanf("%d",&M);
	char T[11];
	for(i=0;i<M;i++){
		flag=0;
		scanf("%s",T);
		for(j=0;j<N;j++){
			if(strcmp(U[j],T)==0){
				flag=1;
				break;
			}
		}
		if(flag==0){
			cout<<"Unknown "<<T<<endl;
		}else if(oc==0){
			cout<<"Opened by "<<T<<endl;
			oc=1;
		}else{
			cout<<"Closed by "<<T<<endl;
			oc=0;
		}
	}


	return 0;
}

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

using namespace std;

int main(){
  int n,m,i,j,k,s=0;
  string id[256],str;
  cin >> n;
  for(i=0;i<n;i++) cin >> id[i];
  cin >> m;
  for(i=0;i<m;i++){
    cin >> str;
    k=0;
    for(j=0;j<n;j++){
      if(id[j]==str) k=1;
    }
    if(k==0) cout << "Unknown " << str << endl;
    else if(s==0) {
      cout << "Opened by " << str << endl;
      s=1;
    }else{
      cout << "Closed by " << str << endl;
      s=0;
    }
  }
   
  
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	int n, m;
	string u[256], t[256];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> u[i];
	cin >> m;
	bool open = false;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
		bool know = false;
		for (int j = 0; j < n; j++) {
			if (t[i] == u[j]) {
				know = true;
				if (!open) {
					open = true;
				}
				else {
					open = false;
				}
				break;
			}
		}
		if (know) {
			if (open)cout << "Opened by " << t[i] << endl;
			else cout << "Closed by " << t[i] << endl;
		}
		else cout << "Unknown " << t[i] << endl;
	}
	return 0;
}

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

int n, m;
string u[256];
bool open;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> u[i];
  open = false;
  scanf("%d", &m);
  string t;
  for (int i = 0; i < m; i++) {
    cin >> t;
    bool flag = true;
    for (int j = 0; j < n; j++) {
      if (t == u[j]) {
        if (open) cout << "Closed by " << t << "\n";
        else cout << "Opened by " << t << "\n";
        open = !open;
        flag = false;
        break;
      }
    }
    if (flag) cout << "Unknown " << t << "\n";
  }
}

C++: #include <stdio.h>

#define MYSCAN scanf

char u[300][20];
int n;

int match(char t[20]);

int main(void){
	int i;
	int m;
	int mat;
	char t[20];
	int door = -1;

	MYSCAN("%d", &n);
	MYSCAN("\n");
	// テァツ卍サテゥツ個イIDテ」ツ?ョテ・ツ?・テ・ツ環?
	for (i = 0; i < n; i++){
		gets(u[i]);
	}

	MYSCAN("%d", &m);
	MYSCAN("\n");
	for (i = 0; i < m; i++){
		// テ」ツつォテ」ツδシテ」ツδ嘉」ツつ津」ツ?凝」ツ?姪」ツ??
		gets(t);
		mat = match(t);
		// テァツ卍サテゥツ個イテ」ツ?陛」ツつ古」ツ?ヲテ」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌」ツつ?
		if (mat == -1){
			printf("Unknown %s\n", t);
		}
		else{
			// テ」ツδ嘉」ツつ「テ」ツ?古ゥツ鳴嘉」ツ?セテ」ツ?」テ」ツ?ヲテ」ツ?淌」ツつ嘉」ツ?づ」ツ?妥」ツつ?
			if (door == -1){
				printf("Opened by %s\n", t);
			}
			// テゥツ鳴凝」ツ??」ツ?ヲテ」ツ?淌」ツつ嘉ゥツ鳴嘉」ツつ?」ツつ?
			else{
				printf("Closed by %s\n", t);
			}
			door *= -1;
		}
	}


	return 0;
}


// テヲツ鳴?・ツュツ療・ツ按療」ツ?古」ツ?づ」ツ?」テ」ツ?ヲテ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツつ津・ツ按、テ・ツョツ堙」ツ?凖」ツつ凝ゥツ鳴「テヲツ閉ー
// テ・ツ青暗ィツ?エテ」ツ?凖」ツつ凝ヲツ鳴?・ツュツ療・ツ按療」ツ?古」ツ?ェテ」ツ?妥」ツつ古」ツ?ー-1テ」ツつ津ィツソツ氾」ツ??
int match(char t[20]){
	int i, j;

	for (i = 0; i < n; i++){
		for (j = 0; t[j] != '\0' && u[i][j] != '\0'; j++){
			if (t[j] != u[i][j]){ break; }
		}
		if (t[j] == '\0' && u[i][j] == '\0'){
			return i;
		}
	}
	return -1;
}

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

using namespace std;

 int main(void) {

	 int N, M;
	 string U[256];
	 string T;
	 bool f = true;
	 bool find;

	 cin >> N;

	 for (int i = 0; i < N; i++){
		 cin >> U[i];
	 }

	 cin >> M;

	 for (int i = 0; i < M; i++){
		 cin >> T;
		 find = false;
		 for (int j = 0; j < N; j++){
			 if (U[j] == T) find = true;
		 }
		 if (find){
			 if (f){
				 f = false;
				 cout << "Opened by ";
			 }
			 else{
				 f = true;
				 cout << "Closed by ";
			 }
		 }
		 else cout << "Unknown ";

		 cout << T << endl;
	 }

	 return 0;
	
}