#include <bits/stdc++.h>
using namespace std;
struct Travel {
  string from;
  string to;
};
string current_place;
int main() {
  int n;
  cin >> n;
  string home;
  cin >> home;
  vector<Travel> travels(n);
  for (int i = 0; i < n; i++) {
    string travel;
    cin >> travel;
    travels[i] = {travel.substr(0, 3), travel.substr(5, 3)};
  }
  current_place = home;
  while (true) {
    auto current_travel =
        find_if(travels.begin(), travels.end(),
                [](const Travel& t) { return t.from == current_place; });
    if (current_travel == travels.cend()) break;
    current_place = current_travel->to;
    travels.erase(current_travel);
  }
  if (current_place == home)
    cout << "home";
  else
    cout << "contest";
  return 0;
}
