#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int arr[8];
  string sno;
  for (int j = 0; j < 10; j++) {
    cin >> sno;
    string s2;
    for (int i = 0; i < 8; i++) {
      int in = i * 10;
      int fi = 10;
      s2 = s.substr(in, fi);
      if (s2.compare(sno) == 0) {
        arr[i] = j;
      }
      s2.clear();
    }
  }
  for (int k = 0; k < 8; k++) {
    cout << arr[k];
  }
}
