#include <bits/stdc++.h>
using namespace std;
int main() {
  string str, result = "", tmp;
  map<string, int> array;
  cin >> str;
  for (long long i = 0; i < 10; i++) cin >> tmp, array[tmp] = i;
  tmp = "";
  for (long long i = 0; i < 80; i++) {
    tmp += str[i];
    if ((i + 1) % 10 == 0) result += array[tmp] + '0', tmp = "";
  }
  cout << result << endl;
  return 0;
}
