#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  map<string, int> cnt;
  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    string from = t.substr(0, 3);
    string to = t.substr(5, 3);
    ++cnt[from];
    --cnt[to];
  }
  cout << (cnt[s] == 0 ? "home" : "contest");
}
