#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  stringstream s;
  string input, line, word, Out;
  cin >> input;
  map<string, int> Binary;
  map<string, int>::iterator k;
  for (int i = 0; i < 10; i++) {
    cin >> line;
    Binary[line] = i;
  }
  for (int i = 0; i < 80; i++) {
    word += input[i];
    if ((i + 1) % 10 == 0) {
      k = Binary.find(word);
      word = "";
      num = (*k).second;
      s << num;
    }
  }
  Out = s.str();
  cout << Out;
  return 0;
}
