#include <bits/stdc++.h>
using namespace std;
string s[10], t;
int main() {
  cin >> t;
  for (int i = 0; i < 10; i++) cin >> s[i];
  for (int i = 0; i < 80; i += 10)
    for (int j = 0; j < 10; j++)
      if (t.substr(i, 10) == s[j]) cout << j;
}
