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>

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 DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

using namespace std;
int main(void)
{
  int n;
  bool locked=true;
  cin >> n;
  set<string> names;
  REP(i,n){
    string tmp;
    cin >> tmp;
    names.insert(tmp);
  }
  cin >> n;
  REP(i,n){
    string tmp;
    cin >> tmp;
    if(names.find(tmp)==names.end())
      cout << "Unknown " << tmp << endl;
    else{
      if(locked) cout << "Opened by " << tmp << endl;
      else cout << "Closed by " << tmp << endl;
      locked=!locked;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
int N,M;
set<string> S;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    string s; cin >> s; S.insert( s );
  }
  cin >> M;
  bool f = false;
  for(int i=0;i<M;i++){
    string s; cin >> s;
    if( S.find( s ) != S.end() ){
      if( !f ){
        cout << "Opened"; f = true;
      } else {
        cout << "Closed"; f = false;        
      }
      cout << " by ";
    } else
      cout << "Unknown ";
    cout << s << endl;
  }
}

C++: // 2016-11-30
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n, m;
	string u[256], t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u[i];
	}
	cin >> m;
	bool o = false;
	for (int i = 0; i < m; i++) {
		cin >> t;
		int j;
		for (j = 0; j < n; j++) {
			if (t == u[j]) {
				cout << (o ? "Closed by " : "Opened by ") << t << endl;
				o ^= true;
				break;
			}
		}
		if (j == m) {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

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

int main(){
	int n,m;
	vector<string> v(256);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	cin >> m;
	bool open = false;
	for(int i=0;i<m;i++){
		string t;
		cin	>> t;
		if(find(v.begin(),v.end(),t) != v.end()){
			if(open){
				cout << "Closed by ";
			} else {
				cout << "Opened by ";
			}
			open=(open+1)%2;
			cout << t << endl;
		} else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	

using namespace std;

namespace MyLib {
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
}
using namespace MyLib;

string u[256];
string t;

int main() {
	int n, m;
	int open = 1;
	int flag = 0;
	cin >> n;
	REP(i, n)
		cin >> u[i];
	cin >> m;
	REP(i, m) {
		cin >> t;
		REP(j, n)
			if (t == u[j])
				if (open)
					cout << "Opened by " << t << endl, open = 0, flag = 1;
				else
					cout << "Closed by " << t << endl, open = 1, flag = 1;
		if (flag)
			flag = 0;
		else
			cout << "Unknown " << t << endl;

	}


	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <string>
#include <set>

using namespace std;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  set<string> lis;
  int st = 0;
  int n, m;

  scanf ( "%d", &n );
  while ( n-- )
  {
    char s[ 11 ];

    scanf ( " %s", s );
    lis.insert ( s );
  }

  scanf ( "%d", &m );
  while ( m-- )
  {
    char s[ 11 ];

    scanf ( " %s", s );
    if ( lis.find ( s ) == lis.end ( ) )
    {
      printf ( "Unknown %s\n", s );
    }
    else
    {
      printf ( "%s by %s\n", ( st ? "Closed" : "Opened" ), s );
      st = !st;
    }
  }

  return ( EXIT_SUCCESS );
}

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

using namespace std;

vector<string> V;

bool find(string in){
  for(int i = 0; i < V.size(); i++)
    if(V[i] == in) return true;

  return false;
}

int main(){
  int n,m;
  

  cin >> n;
  while(n--){
    string in;
    cin >> in;
    V.push_back(in);
  }

  bool open = false;

  cin >> m;
  while(m--){
    string in;
    cin >> in;
    if(find(in)){
      if(open) cout << "Closed by ";
      else cout << "Opened by ";
      open = !open;
    }else cout << "Unknown ";

    cout << in << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	set<string> se;
	rep(i,n){
		string s; cin >> s;
		se.insert(s);
	}
	ll m; cin >> m;
	ll open = 0;
	rep(i,m){
		string s; cin >> s;
		if(se.find(s) == se.end()) print2("Unknown",s);
		else{
			if(open) print2("Closed by",s);
			else print2("Opened by",s);
			open = !open;
		}
	}
}