#include <bits/stdc++.h>
int main() {
  int i, k, j = 0;
  char *str = new char[85];
  char password[10];
  char mas[10][12];
  scanf("%s", str);
  for (i = 0; i < 10; i++) {
    scanf("%s", &mas[i]);
  }
  for (i = 0; i < 8; i++) {
    for (k = 0; k < 10; k++) {
      if (strncmp(mas[k], str, 10) == 0) {
        password[j++] = k + 48;
        break;
      }
    }
    str = str + 10;
  }
  password[j] = '\0';
  printf("%s", password);
  return 0;
}
