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