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>

#define INF (1001001001)

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

using namespace std;

int main()
{
	int n, m;

	scanf("%d", &n);

	vector<string> ids(n);

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

	bool door = false;

	scanf("%d", &m);

	for (int i = 0; i < m; i++){
		string id;

		cin >> id;

		for (int j = 0; j < n; j++){
			if (id == ids[j]){
				if (door == false){
					cout << "Opened by " << id << endl;

					door = true;
				}
				else {
					cout << "Colosed by " << id << endl;

					door = false;
				}

				break;
			}

			if (j == n - 1){
					cout << "Unknown " << id << endl;
			}
		}
	}

	return (0);
}

C++: #include <iostream>
#include <unordered_set>
using namespace std;
class Door {
  public:
    bool isOpened;
    void openedBy(string id) {
      isOpened = true;
      cout << "Opened by " << id << endl;
    }
    void closedBy(string id) {
      isOpened = false;
      cout << "Closed by " << id << endl;
    }
    void toggledBy(string id) {
      (isOpened) ? closedBy(id) : openedBy(id);
    }
};

int main() {
  unordered_set<string> registedIds;
  int nRegistedIds;
  cin >> nRegistedIds;
  for(int i = 0; i < nRegistedIds; ++i) {
    string id;
    cin >> id;
    registedIds.insert(id);
  }
  Door door;
  int nTryIds;
  cin >> nTryIds;
  for(int i = 0; i < nTryIds; ++i) {
    string id;
    cin >> id;
    if(registedIds.find(id) != registedIds.end()) {
      door.toggledBy(id);
    } else {
      cout << "Unknown " << id << endl;
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
    
    int n,m;
    cin >> n;
    bool Open = 0;
    string c;
    vector<string> str;
    
    for(int i=0;i<n ;i++){
        
                cin >> c;
                str.push_back(c);
    }
    
    cin >> m;
    for(int i=0;i<m;i++){
        bool f = 1;
        string c;
        cin >> c;
        for(int j=0;j<n;j++){
        
            if(str[j] == c && Open == 0){
                cout << "Opened by " << c << endl;
                Open = 1;
                f = !f;
                break;
            }
            if(str[j] == c && Open == 1){
                cout << "Closed by " << c << endl;
                Open = 0;
                f = !f;
                break;
            }
        }
        if(f){
            cout << "Unknown " << c << endl;
            f = !f;
        }
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

bool solve() {
  int N;
  map<string, int> m;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    m[s] = 0;
  }
  int M;
  cin >> M;
  int cur = 0;
  for (int i = 0; i < M; i++) {
    string s;
    cin >> s;
    if (m.find(s) == m.end()) {
      cout << "Unknown " << s << endl;
      continue;
    }
    if (cur == 0)
      cout << "Opened by " << s << endl;
    else
      cout << "Closed by " << s << endl;
    cur = 1 - cur;
  }
  return true;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  // while (solve()) {}
  return 0;
}