#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[80];
  string pass = "";
  cin >> str;
  string bins[10];
  for (int i = 0; i < 10; i++) cin >> bins[i];
  for (int i = 0; i < 80; i = i + 10) {
    string temp = "";
    for (int x = 0; x < 10; x++) temp += str[x + i];
    for (int x = 0; x < 10; x++)
      if (bins[x] == temp) pass += to_string(x);
  }
  cout << pass;
}
