#include <bits/stdc++.h>
using namespace std;
int hashCh = 31;
struct HashCh {
  string code;
  int number;
};
long long getHash(string text) {
  long long hash = 0;
  int size = text.size();
  for (int i = 0; i < size; i++) {
    int ch = static_cast<int>(text[i]);
    hash += pow(hashCh, i) * ch;
  }
  return hash;
}
int main() {
  vector<string> password;
  map<long long, HashCh> numbers;
  char buf[80];
  string oneNumber;
  for (int i = 0; i < 80; i++) {
    char ch;
    cin >> ch;
    oneNumber += ch;
    if ((i % 10) == 9) {
      password.push_back(oneNumber);
      oneNumber = "";
    }
  }
  for (int i = 0; i < 10; i++) {
    string number;
    cin >> number;
    HashCh ch = HashCh();
    ch.code = number;
    ch.number = i;
    long long hash = getHash(number);
    numbers[hash] = ch;
  }
  vector<int> result;
  for (int i = 0; i < 8; i++) {
    auto it = numbers.find(getHash(password[i]));
    if (it != numbers.end() && it->second.code == password[i]) {
      result.push_back(it->second.number);
    }
  }
  for (auto i = result.begin(); i != result.end(); i++) {
    cout << *i;
  }
  return 0;
}
