#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  map<string, int> keys;
  for (int i = 0; i <= 9; i++) {
    string ts;
    cin >> ts;
    keys[ts] = i;
  }
  for (int i = 0; i < 8; i++) {
    string p = s.substr(i * 10, 10);
    cout << keys[p];
  }
  cout << endl;
}
