#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const double eps = 0.00000001;
void solve() {
  string s;
  string a[10];
  string b[10];
  cin >> s;
  for (int i = 0; i < 10; i++) cin >> a[i];
  int j = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    if (i % 10 == 0 && i != 0) j++;
    b[j] += s[i];
  }
  for (int j = 0; j < 10; j++) {
    for (int i = 0; i < 10; i++) {
      if (a[i] == b[j]) cout << i;
    }
  }
  cout << endl;
}
int main() { solve(); }
