#include <bits/stdc++.h>
using namespace std;
int main() {
  int b = -1, n = 0, limit = 10;
  string pass, box = "0000000000", zero, one, two, three, four, five, six,
               seven, eight, nine;
  cin >> pass;
  cin >> zero;
  cin >> one;
  cin >> two;
  cin >> three;
  cin >> four;
  cin >> five;
  cin >> six;
  cin >> seven;
  cin >> eight;
  cin >> nine;
  while (n < 8) {
    for (int i = b + 1, i2 = 0; i < limit; i++, i2++) {
      box[i2] = pass[i];
      b = i;
    }
    if (box == zero)
      cout << "0";
    else if (box == one)
      cout << "1";
    else if (box == two)
      cout << "2";
    else if (box == three)
      cout << "3";
    else if (box == four)
      cout << "4";
    else if (box == five)
      cout << "5";
    else if (box == six)
      cout << "6";
    else if (box == seven)
      cout << "7";
    else if (box == eight)
      cout << "8";
    else if (box == nine)
      cout << "9";
    n++;
    limit += 10;
  }
  return 0;
}
