#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> data;
  string code, info;
  string container[10];
  cin >> code;
  for (int i = 0; i < 10; i++) {
    cin >> info;
    container[i] = info;
    data[info] = i;
  }
  string substring;
  for (int i = 0; i < 8; i++) {
    substring = code.substr(i * 10, 10);
    for (int j = 0; j < 10; j++) {
      if (substring == container[j]) cout << data[substring];
    }
  }
  return 0;
}
