#include <bits/stdc++.h>
using namespace std;
int main() {
  string line;
  string codes[10];
  getline(cin, line);
  for (int i = 0; i < 10; i++) {
    getline(cin, codes[i]);
  }
  int start = 0;
  string ans = "";
  while (1) {
    if (start == 80) break;
    string tmp = line.substr(start, 10);
    for (int i = 0; i < 10; i++) {
      if (tmp == codes[i]) {
        ans += (char)(i + '0');
        break;
      }
    }
    start = start + 10;
  }
  cout << ans << endl;
  return 0;
}
