#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> v, vv;
  string s, temp = "", ss;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    temp += s[i];
    if (temp.size() == 10) {
      v.push_back(temp);
      temp = "";
    }
  }
  for (int i = 0; i < 10; i++) cin >> ss, vv.push_back(ss);
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 10; j++) {
      if (v[i] == vv[j]) {
        cout << j;
        break;
      }
    }
  }
  return 0;
}
