#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535897;
int main() {
  string pass;
  string str[10];
  cin >> pass;
  for (int i = 0; i < 10; i++) {
    cin >> str[i];
  }
  for (int i = 0; i < 80; i += 10) {
    string tmp = pass.substr(i, 10);
    for (int io = 0; io < 10; io++) {
      if (tmp == str[io]) {
        cout << io;
        break;
      }
    }
  }
  return 0;
}
