#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  char t[40][40];
  cin >> s;
  for (int i = 0; i < 10; i++) scanf("%s", &t[i]);
  for (int i = 0; i < 8; i++) {
    char buffer[100];
    size_t length = s.copy(buffer, 10, i * 10);
    buffer[length] = '\0';
    for (int j = 0; j < 10; j++) {
      if (strcmp(t[j], buffer) == 0) printf("%d", j);
    }
  }
  return 0;
}
