#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int main() {
  string s, p;
  int n, i, k, j;
  cin >> s;
  for (i = 0; i < 10; i++) {
    cin >> p;
    mp[p] = i;
  }
  p = "";
  for (i = 0; i < s.length(); i++) {
    p += s[i];
    if (p.length() == 10) {
      cout << mp[p];
      p = "";
    }
  }
}
