#include <bits/stdc++.h>
using namespace std;
char en[100];
char num[10][15];
int de[10];
char tmpp[15];
int main() {
  {
    scanf("%s", en);
    for (int i = 0; i < 10; ++i) scanf("%s", num[i]);
    memset(de, 0, sizeof(de));
    int tmp;
    for (int i = 0; i < 8; ++i) {
      tmp = i * 10;
      memcpy(tmpp, en + tmp, 10 * sizeof(char));
      for (int j = 0; j < 10; ++j) {
        if (strcmp(tmpp, num[j]) == 0) {
          de[i] = j;
          break;
        }
      }
    }
    for (int i = 0; i < 8; ++i) printf("%d", de[i]);
    puts("");
  }
  return 0;
}
