#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  string str;
  cin >> str;
  string ara[10];
  int flag = 0;
  for (int i = 0; i < 10; i++) cin >> ara[i];
  int length = 0;
  string s1;
  for (int i = 0; i < 80; i++) {
    s1.push_back(str[i]);
    length++;
    if (length == 10) {
      for (int i = 0; i < 10; i++) {
        if (s1 == ara[i]) cout << i;
      }
      s1.clear();
      length = 0;
    }
  }
  cout << endl;
  return 0;
}
