#include <bits/stdc++.h>
using namespace std;
void find(string &pw, string *code) {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 10; j++) {
      bool flag = true;
      for (int k = 0; k < 10; k++)
        if (pw[i * 10 + k] != code[j][k]) {
          flag = false;
          break;
        }
      if (flag) {
        cout << j;
        break;
      }
    }
  }
  cout << endl;
}
int main() {
  string pw, code[10];
  while (cin >> pw) {
    for (int i = 0; i < 10; i++) cin >> code[i];
    find(pw, code);
  }
  return 0;
}
