#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
const double PI = 3.14159;
vector<string> v;
long long n, m, k, t, sum, r, l, d, b, c, a;
long long ans;
map<string, int> mp;
string s;
bool f;
stack<char> st;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> s;
  for (int i = 0; i < 10; i++) {
    string x;
    cin >> x;
    mp[x] = i;
  }
  for (int i = 0; i < s.size(); i += 10) {
    cout << mp[s.substr(i, 10)];
  }
  return 0;
}
