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 <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int main(int argc, char *argv[])
{
  map<string,int> key;
  int n;
  cin >> n;
  string in;  
  rep(i,n){
    cin >> in;
    key[in]=0;
  }

  cin >> n;
  rep(i,n){
    cin >> in;
    if(key.count(in)){
      cout << (!key[in]?"Opened":"Closed") << " " << in << endl;
      key[in]^=1;
    }else cout << "Unknown " << in << endl;
  }
  
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  map<string, bool> t;
  rep(i, n) {
    string s;
    cin >> s;
    t[s] = true;
  }
  int m;
  cin >> m;
  bool d = false;
  rep(i, m) {
    string s;
    cin >> s;
    if (t.count(s)) {
      d ^= 1;
      cout << (d ? "Opened" : "Closed") << " by " << s << endl;
    } else {
      cout << "Unknown " << s << endl;
    }
  }
}

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

using namespace std;

#define open 1
#define close 0

int search;
bool key;

void judge(int N, int M, char U[300][12], char T[300][12])
{
	for(int j = 0; j < M; j++){
		for(int i = 0; i < N; i++){
			if(strcmp(U[i], T[j]) == 0){
				if(key == close){
					cout << "Opened by ";
					printf("%s\n", T[j]);
					key = open;
				}
				else if(key == open){
					cout << "Closed by ";
					printf("%s\n", T[j]);
					key = close;
				}
				search = true;
			}
		}
		if(search == false){
			cout << "Unknown ";
			printf("%s\n", T[j]);
		}
		search = false;
	}
}
			

int main()
{
	int N, M;
	char U[300][12];
	char T[300][12];
	
	while(scanf("%d", &N) != EOF){
		for(int i = 0; i < N; i++){
			cin >> U[i];
		}
		cin >> M;
		for(int i = 0; i < M; i++){
			cin >> T[i];
		}
		key = close;
		judge(N, M, U, T);		
	}
	return 0;
}

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

int main() {
	int N, M;
	bool s = false;
	string U[256], T[256];

	cin >> N;
	for (int i = 0; i < N; ++i) cin >> U[i];
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> T[i];
		int f = 0;
		for (int j = 0; j < N; ++j) {
			if (T[i] == U[j]) {
				s = !s;
				if (s) cout << "Opened by ";
				else cout << "Closed by ";
				f = 1;
				break;
			}
		}
		if (!f) cout << "Unknown ";
		cout << T[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    set<string> s;
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        s.insert(S);
    }
    bool open = false;
    int M;
    cin >> M;
    for(int i=0; i<M; i++){
        string S;
        cin >> S;
        if(s.count(S)){
            if(open){
                cout << "Closed by " << S << enld;
            }else{
                cout << "Opened by " << S << enld;
            }
            open ^= true;
        }else{
            cout << "Unknown " << S << enld;
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,cnt=0;
  int cnt2=0;

  cin >> n;
  
  string a[n];
  
  for(int i =0;i<n;i++){
    cin >> a[i];
  }

  cin >> m ;
  string b[m];
  
  for(int i=0;i<m;i++){
    cin >>b[i];
    for(int j=0;j<n;j++){
      if(b[i]==a[j] && cnt % 2 == 0){
	cnt++;
	cnt2++;
	cout << "Opened by " << b[i] << endl;
	break;
      } 
      else if(b[i]==a[j] && cnt % 2 == 1){
	cnt++;
	cnt2++;
	cout << "Closed by " << b[i] << endl;
	break;
      }
    }
    if(cnt2 == 0)cout << "Unknown " << b[i] << endl;
    cnt2 =0;
    }
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>

using namespace std;

unordered_map<string, bool> check;

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        check[str] = true;
    }
    int m;
    cin >> m;
    bool closed = true;
    for (int i = 0; i < m; i++) {
        string str;
        cin >> str;
        if (check.find(str) == check.end()) {
            cout << "Unknown " << str << endl;
        } else {
            if (not closed) {
                cout << "Closed by " << str << endl;
                closed = true;
            } else {
                cout << "Opened by " << str << endl;
                closed = false;
            }
        }
    }
    return 0;
}