#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
using namespace std;
int main() {
  int n;
  char s[5], aux1[5], aux2[5];
  int cont1 = 0, cont2 = 0;
  scanf(" %d %c%c%c", &n, &s[0], &s[1], &s[2]);
  for (int i = (int)(0); i < (int)(n); ++i) {
    scanf(" %c%c%c->%c%c%c", &aux1[0], &aux1[1], &aux1[2], &aux2[0], &aux2[1],
          &aux2[2]);
    if (aux1[0] == s[0] && aux1[1] == s[1] && aux1[2] == s[2]) {
      cont1++;
    }
    if (aux2[0] == s[0] && aux2[1] == s[1] && aux2[2] == s[2]) {
      cont2++;
    }
  }
  if (cont1 == cont2 && cont1 + cont2 == n) {
    cout << "home" << endl;
  } else {
    cout << "contest" << endl;
  }
  return 0;
}
