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++: #pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define rep(i,n) for(LL i=0;i<n;i++)
#define rep2(i,j,a,h,w) for(LL i=0;i<h;i++)for(LL j=0;j<w;j++)cin>>a[i][j]
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion





#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<int>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<int, int>;
using ppi = pair<pi, int>;
using mll = map<int, int>;
using mcl = map<char, int>;
using msb = map<st, bool>;
using vpi = vector<pi>;
using vppi = vector<ppi>;
using qpi = queue<pi>;

#pragma endregion

//十字移動のみ
int cross_x[] = { -1,0,0,1 };
int cross_y[] = { 0,1,-1,0 };



void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	if (b == 0) {
		swap(a, b);
	}
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}


//素因数分解
void dec_prime(int n) {
	int a = 2;
	while (a*a <= n) {
		if (n % a == 0) {
			cout << a << endl;
			n /= a;
		}
		else {
			a++;
		}
	}
	cout << n << endl;
}

//エラトステネスの篩
void sieve_prime(LL n) {
	vb s(n + 1, true);
	f(i, 2, n + 1) {
		for (int j = 2; i*j <= n; j++) {
			s[i*j] = false;
		}
	}
	cout << "2から" << n << "までの素数" << endl;
	f(i, 2, n + 1) {
		if (s[i]) {
			cout << i << " ";
		}
	}
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= MOD;
	}
	return ret;
}


#pragma endregion 

vi par;

int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}

void unite(int x, int y) {
	if (root(x) == root(y)) {
		return;
	}
	else {
		par[root(x)] = root(y);
		return;
	}
}

bool same(int x, int y) {
	return root(x) == root(y);
}

struct edge {
	int to;
	int cost;
};

/*****************************************************************************/
signed main() {

	int n;
	cin >> n;
	vs u(n);
	msb k;
	rep(i, n) {
		cin >> u[i];
		k[u[i]] = true;
	}
	int m;
	cin >> m;
	vs t(m);
	rep(i, m) {
		cin >> t[i];
	}
	int cnt = 0;
	rep(i, m) {
		if (k[t[i]]) {
			if (cnt % 2 != 0) {
				cout << "Closed by " << t[i] << endl;
			}
			else {
				cout << "Opened by " << t[i] << endl;
			}
			cnt++;
		}
		else {
			cout << "Unknown " << t[i] << endl;
		}
	}
	return 0;
}

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

int main() {
  int n, m;
  cin >> n;
  vector<string> u(n);
  rep (i, n) cin >> u[i];

  cin >> m;
  vector<string> t(m);
  rep (i, m) cin >> t[i];

  vector<bool> ut(m);
  rep (i, m) {
    bool solved = false;

    rep (j, n) {
      if (t[i] == u[j]) {
        if (ut[i]) {
          cout << "Closed by " << t[i] << endl;
          ut[i] = false;
          solved = true;
        }
        else {
          cout << "Opened by " << t[i] << endl;
          ut[i] = true;
          solved = true;
        }
        break;
      }
    }

    if (!solved) cout << "Unknown " << t[i] << endl;
  }

  return 0;
}

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

int main(){
	set<string> user;
	bool open=false;
	string name;
	int n,m;
	cin>>n;
	while(n--){
		cin>>name;
		user.insert(name);
	}
	cin>>m;
	while(m--){
		cin>>name;
		if(user.find(name)!=user.end()){
			if(open)cout<<"Closed by ";
			else cout<<"Opened by ";
			cout<<name<<endl;
			open=!open;
		}else{
			cout<<"Unknown "<<name<<endl;
		}
	}
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int N,M;
	bool open = false;
	std::string T;
	getline(cin, T);
	N = atoi(T.c_str());
	std::string *u = new std::string[ N ];
	for (int i = 0; i < N; i++) {
		getline(cin, u[i]);
	}
	getline(cin, T);
	M = atoi(T.c_str());
	for (int i = 0; i < M; i++) {
		bool find = false;
		getline(cin, T);
		for (int j = 0; j < N && (!find); j++) {
			if (T == u[j]) {
				find = true;
			}
		}
		if (find) {
			if (!open) {
				cout << "Opened by " << T << endl;
				open = true;
			}else {
				cout << "Closed by " << T << endl;
				open = false;
			}
		}else {
			cout << "Unknown " << T << endl;
		}
	}
	delete[] u;
	return 0;
}

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

int main(){
  int num_1,num_2;
  int i,j;
  int OK=0;
  string ID[257];
  string ID_2;
  int flg=0; //flg = 0→施錠 flg = 1→開錠 
  cin >> num_1;
  for(i = 0 ; i < num_1 ; i++){
    cin >> ID[i];
  }

  cin >> num_2;

  for(i = 0 ; i < num_2 ; i++){
    int flg_2 = 0;
    cin >> ID_2;
    for(j = 0 ; j < num_1 ; j++){
      if(ID_2==ID[j]&&flg==0){
	flg = 1;
	flg_2 = 1;
	cout << "Opened by" << " " << ID_2 << endl;
      }else if(ID_2==ID[j]&&flg==1){
	flg = 0;
	flg_2 =1;
	cout << "Closed by" << " " << ID_2 << endl;
      }else{
	continue;
      }
    }
    if(flg_2 == 0){
      cout << "Unknown" << " " << ID_2 << endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  set<string> se;
  while (n--) {
    string s; cin >> s;
    se.insert(s);
  }
  int m; cin >> m;
  bool b = true;
  while (m--) {
    string s; cin >> s;
    if (se.count(s)) {
      cout << (b ? "Opened" : "Closed") << " by " << s << '\n';
      b ^= true;
    } else {
      cout << "Unknown " << s << '\n';
    }
  }
}