#include <bits/stdc++.h>
using namespace std;
char f;
string tas[1000], mas;
long a, b, kol, m, n, pos, mi, ma, nn, kola, kolb;
double k;
long long ans;
int main() {
  cin >> mas;
  for (int a = 0; a < (10); a++) cin >> tas[a];
  for (int a = 0; a < (8); a++) {
    for (int b = 0; b < (10); b++) {
      if (mas.substr(a * 10, 10) == tas[b]) cout << b;
    }
  }
}
