#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  string numbers[10];
  for (long long i = 0; i < ((long long)10); i++) cin >> numbers[i];
  long long res = 0;
  for (long long i = 0; i < ((long long)8); i++) {
    res *= 10;
    int ok = 0;
    for (long long j = 0; j < ((long long)10); j++)
      if (str.substr(i * 10, 10) == numbers[j]) ok = j;
    res += ok;
  }
  printf("%08lld\n", res);
}
