#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<string> vec, vec2;
  string s, s1;
  cin >> s;
  int i = 0, c = 0, j = 0;
  while (c != 8) {
    s1 += s[i++];
    j++;
    if (j == 10) {
      vec.push_back(s1);
      s1 = "";
      c++;
      j = 0;
    }
  }
  string s2;
  for (int i = 0; i < 10; i++) {
    cin >> s2;
    vec2.push_back(s2);
  }
  for (int i = 0; i < vec.size(); i++)
    for (int j = 0; j < vec2.size(); j++)
      if (vec[i] == vec2[j]) cout << j;
  cout << endl;
  return 0;
}
