#include <bits/stdc++.h>
using namespace std;
int main() {
  string pwd;
  string code[10];
  cin >> pwd;
  for (auto& s : code) cin >> s;
  for (int i = 0; i < 80; i += 10) {
    cout << find(code, code + 10, pwd.substr(i, 10)) - code;
  }
  cout << endl;
  return 0;
}
