#include <bits/stdc++.h>
using namespace std;
string str;
string l;
map<string, int> m;
string Greedy_Solve() {
  string res = "";
  for (int i = 0; i < l.length(); i += 10) {
    str = l.substr(i, 10);
    res += m[str] + '0';
  }
  return res;
}
int main() {
  cin >> l;
  for (int i = 0; i < 10; i++) {
    cin >> str;
    m[str] = i;
  }
  cout << Greedy_Solve();
  return 0;
}
