#include <bits/stdc++.h>
using namespace std;
string s, f, arr[10];
int main() {
  cin >> s;
  for (int i = 0; i < 10; i++) {
    cin >> f;
    arr[i] = f;
  }
  for (int i = 0; i + 10 <= s.size(); i += 10) {
    string x = s.substr(i, 10);
    for (int j = 0; j < 10; j++) {
      if (x == arr[j]) {
        cout << j;
        break;
      }
    }
  }
  cout << endl;
  return 0;
}
