#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
bool is_vowel(char c) {
  c = tolower(c);
  return c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u' || c == 'y';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string base;
  cin >> base;
  string nums[10];
  for (int i = 0; i < 10; i++) cin >> nums[i];
  for (int i = 0; i < 80; i += 10) {
    for (int j = 0; j < 10; j++) {
      if (nums[j] == base.substr(i, 10)) cout << j;
    }
  }
  return 0;
}
