#include <bits/stdc++.h>
int main() {
  std::unordered_map<std::string, unsigned short int> map;
  std::string input;
  input.reserve(80);
  std::getline(std::cin, input);
  std::string temp;
  temp.reserve(10);
  for (unsigned short int i = 0; i <= 9; i++) {
    std::getline(std::cin, temp);
    map.insert({temp, i});
  }
  std::string result;
  for (size_t i = 0; i < input.size(); i += 10) {
    result += map.find(input.substr(i, 10))->second + '0';
  }
  std::cout << result << std::endl;
}
