#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m, a, b;
  long nn = 0, mm = 0;
  string s, s1, s2;
  vector<string> v;
  cin >> s;
  for (int i = 0; i < 10; i++) {
    cin >> s1;
    v.push_back(s1);
  }
  for (int i = 0; i < 80; i = i + 10) {
    s2 = "";
    for (int j = i; j < i + 10; j++) s2 += s[j];
    for (int k = 0; k < 10; k++) {
      if (s2 == v[k]) {
        cout << k;
        break;
      }
    }
  }
  return 0;
}
