#include <bits/stdc++.h>
using namespace std;
int main() {
  char x[110][4], y[110][4], home[4];
  char s[15];
  int n, i, j, h = 0, t = 0;
  scanf("%d", &n);
  getchar();
  scanf("%s", home);
  for (i = 1; i <= n; i++) {
    getchar();
    scanf("%s", s);
    if ((s[0] == home[0]) && (s[1] == home[1]) && (s[2] == home[2])) {
      h++;
      x[h][1] = s[5];
      x[h][2] = s[6];
      x[h][3] = s[7];
    }
    if ((s[5] == home[0]) && (s[6] == home[1]) && (s[7] == home[2])) {
      t++;
      y[t][1] = s[0];
      y[t][2] = s[1];
      y[t][3] = s[2];
    }
  }
  bool p;
  for (i = 1; i <= h; i++) {
    p = true;
    for (j = 1; j <= t; j++) {
      if ((x[i][1] == y[j][1]) && (x[i][2] == y[j][2]) &&
          (x[i][3] == y[j][3])) {
        p = false;
        x[i][1] = ' ';
        x[i][2] = ' ';
        x[i][3] = ' ';
        y[j][1] = ' ';
        y[j][2] = ' ';
        y[j][3] = ' ';
        break;
      }
    }
    if (p == true) {
      cout << "contest";
      return 0;
    }
  }
  cout << "home";
  return 0;
}
