#include <bits/stdc++.h>
const int mod = 1000000007;
using namespace std;
void solve();
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
void solve() {
  int t;
  cin >> t;
  string s;
  cin >> s;
  int starting = 0, ending = 0;
  while (t--) {
    string s1;
    cin >> s1;
    int tot = int(s1.size()) - 1;
    if ((s1[tot] == s[2]) and (s1[tot - 1] == s[1]) and
        (s1[tot - 2] == s[0]) and (s1[tot - 3] == '>'))
      ending++;
    if (s1[0] == s[0] and s1[1] == s[1] and s1[2] == s[2] and s1[3] == '-') {
      starting++;
    } else if (s1[tot] == s[2] and s1[tot - 1] == s[1] and
               s1[tot - 2] == s[0] and s[tot - 3] == '>') {
    }
  }
  if (ending == starting) {
    cout << "home" << endl;
  } else {
    cout << "contest" << endl;
  }
}
