#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long int linf = 0x3f3f3f3f3f3f3f3f;
const long double pi = acos(-1.0);
const int mod = 1e9 + 7;
const int maxn = 100050;
map<string, int> mapa;
int main() {
  ios::sync_with_stdio(false);
  string texto;
  cin >> texto;
  for (int i = 0; i < 10; i++) {
    string second;
    cin >> second;
    mapa[second] = i;
  }
  for (int i = 0; i <= 70; i += 10) {
    string second;
    for (int j = 0; j < 10; j++) {
      second += texto[i + j];
    }
    cout << mapa[second];
  }
  cout << endl;
  return 0;
}
