#include <bits/stdc++.h>
using namespace std;
string input;
string temp;
map<string, int> convert;
int i;
int main() {
  cin >> input;
  for (i = 0; i < 10; ++i) {
    cin >> temp;
    convert[temp] = i;
  }
  for (i = 0; i < input.length(); i += 10) cout << convert[input.substr(i, 10)];
  return 0;
}
