#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> ans;
  string code, x;
  cin >> code;
  string num0, num1, num2, num3, num4, num5, num6, num7, num8, num9;
  cin >> num0 >> num1 >> num2 >> num3 >> num4 >> num5 >> num6 >> num7 >> num8 >>
      num9;
  for (int i = 0; i < 80; i += 10) {
    x = code.substr(i, 10);
    if (x == num0)
      ans.push_back(0);
    else if (x == num1)
      ans.push_back(1);
    else if (x == num2)
      ans.push_back(2);
    else if (x == num3)
      ans.push_back(3);
    else if (x == num4)
      ans.push_back(4);
    else if (x == num5)
      ans.push_back(5);
    else if (x == num6)
      ans.push_back(6);
    else if (x == num7)
      ans.push_back(7);
    else if (x == num8)
      ans.push_back(8);
    else if (x == num9)
      ans.push_back(9);
  }
  for (int j = 0; j < ans.size(); j++) {
    cout << ans[j];
  }
}
