#include <bits/stdc++.h>
using namespace std;
enum { Right = 0, down, Left, up, rightdown, leftdown, leftup, rightup };
const int p_row[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int p_col[] = {1, 0, -1, 0, 1, -1, -1, 1};
int main() {
  map<string, int> m;
  string g, t;
  cin >> g;
  for (int i = 0; i != (int)10; ++i) {
    cin >> t;
    m[t] = i;
  }
  for (int i = 0; i != (int)8; ++i) {
    cout << m[(g.substr(i * 10, 10))];
  }
  return 0;
}
