#include <bits/stdc++.h>
int main() {
  char s[81], *t[10];
  int ct = 0, k, j, i, w1, w2, a[27] = {0}, b[27] = {0}, flag = 0, start;
  gets(s);
  for (i = 0; i <= 9; i++) {
    t[i] = (char*)malloc(sizeof(char) * 10);
    gets(t[i]);
  }
  for (i = 0; i < 80; i += 10) {
    for (j = 0; j <= 9; j++) {
      if (strncmp(t[j], s + i, 10) == 0) {
        printf("%d", j);
        break;
      }
    }
  }
  return 0;
}
