#include <bits/stdc++.h>
using namespace std;
map<string, int> fr;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int k = 0; k <= 9; k++) {
    string a;
    cin >> a;
    fr[a] = k;
  }
  int id = 0;
  string act = "";
  for (int k = 0; k < 80; k++) {
    act += s[k];
    id++;
    if (id == 10) {
      cout << fr[act];
      id = 0;
      act = "";
    }
  }
  return 0;
}
