#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
static const int mod1 = 1000000007;
static const int mod2 = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
  string isq, s;
  cin >> isq;
  map<string, int> m;
  for (long long i = 0; i < 10; i += 1) {
    cin >> s;
    m[s] = i;
  }
  int j = 0;
  map<string, int>::iterator it;
  while (j < isq.size()) {
    string temp = isq.substr(j, 10);
    it = m.find(temp);
    cout << it->second;
    j += 10;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
