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 <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  set<string> SET;
  int N;cin>>N;
  FOR(i,0,N) {
    string s;
    cin >> s;
    SET.insert(s);
  }
  int M;cin>>M;
  bool open = false;
  FOR(i,0,M) {
    string s;
    cin >> s;
    if(SET.count(s)) {
      if(!open) {
        cout << "Opened by " << s << endl;
        open = true;
      } else {
        cout << "Closed by " << s << endl;
        open = false;
      }
    } else {
      cout << "Unknown " << s << endl;
    }
  }
  return 0;
}

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

int main(){
  int N,M;
  bool f = false;
  vector<string> s;

  cin >> N;

  s.resize(N);

  string work;
  for(int i=0;i<N;++i){
    cin >> work;
    s.emplace_back(work);
  }

  cin >> M;
  
  for(int ix=0;ix<M;++ix){
    cin >> work;

    for(int i=0;i<s.size();++i){
      if(s[i] == work){
	f = !f;
	if(f){
	  cout << "Opened by " << work << endl;
	}else{
	  cout << "Closed by " << work << endl;
	}
	break;
      }
      if(i == s.size() - 1){
	cout << "Unknown " << work << endl;
      }
    }
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin>>n;
    bool status=0;
    string u[300];
    string t[300];
    for(int i=0;i<n;i++)cin>>u[i];
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>t[i];
        int check=0;
        for(int j=0;j<n;j++){
            if(t[i]==u[j])check=1;
        }
        if(!check){
            cout<<"Unknown "<<t[i]<<endl;
        }else{
            if(!status){
                cout<<"Opened by "<<t[i]<<endl;
            }else{
                cout<<"Closed by "<<t[i]<<endl;
            }
            status=!status;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int m,n;
  char u[300][15]={};
  char t[300][15]={};
  int i,j;

  cin>>n;
  rep(i,n)
    cin>>u[i];
  cin>>m;
  bool ans=false;//close
  rep(i,m){
    cin>>t[i];
    rep(j,n)
      if(strcmp(t[i],u[j])==0){
	if(ans){
	  ans=false;
	  printf("Closed by ");
	}else{
	  ans=true;
	  printf("Opend by ");
	}
	cout<<t[i]<<endl;
	goto END;
      }
    printf("Unknown %s\n",t[i]);
  END:;
  }
}

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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;


int main(){
	int N,M;
	cin>>N;
	set<string>st;
	REP(i,N){
		string str;
		cin>>str;
		st.insert(str);
	}
	cin>>M;
	int flag=0;
	REP(i,M){
		string str;
		cin>>str;
		if(st.find(str)!=st.end()){
			if(flag==0){
				cout<<"Opened by "<<str<<endl;
			}else{
				cout<<"Closed by "<<str<<endl;
			}
			flag++;
			flag%=2;
		}else{
			cout<<"Unknown "<<str<<endl;
		}
	}
	return 0;
}