#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> mp;
  string s, s1;
  cin >> s;
  for (int i = 0; i < 10; i++) {
    cin >> s1;
    mp[s1] = i;
  }
  string ss;
  for (int i = 1; i <= 80; ++i) {
    ss = ss + s[i - 1];
    if (i % 10 == 0) {
      cout << mp[ss];
      ss = "";
    }
  }
}
