#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char s[80];
  cin >> s;
  string a;
  int n = 10;
  unordered_map<string, int> ht;
  for (int i = 0; i < 10; i++) {
    cin >> a;
    ht[a] = i;
  }
  int i = 10;
  while (i <= 80) {
    a = "";
    for (int j = i - 10; j < i; j++) {
      a += s[j];
    }
    cout << ht[a];
    i += 10;
  }
  cout << "\n";
}
