#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int n;
  cin >> n;
  vector<string> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  long long int i, j;
  for (j = 0; j < n; j++) {
    string t = v[j];
    if (s.size() == t.size()) {
      for (i = 0; i < s.size(); i++) {
        if (s[i] == t[i])
          continue;
        else if (s[i] >= 'a' && s[i] <= 'z') {
          if (s[i] - 'a' + 'A' == t[i])
            continue;
          else if (s[i] - 'a' + 'A' == 'O' &&
                   (t[i] == '0' || t[i] == 'o' || t[i] == 'O'))
            continue;
          else if ((s[i] - 'a' + 'A' == 'L' || s[i] - 'a' + 'A' == 'I') &&
                   (t[i] == 'L' || t[i] == 'l' || t[i] == 'i' || t[i] == 'I' ||
                    t[i] == '1'))
            continue;
          else
            break;
        } else if (s[i] >= 'A' && s[i] <= 'Z') {
          if (s[i] - 'A' + 'a' == t[i])
            continue;
          else if (s[i] - 'A' + 'a' == 'o' &&
                   (t[i] == '0' || t[i] == 'o' || t[i] == 'O'))
            continue;
          else if ((s[i] - 'A' + 'a' == 'l' || s[i] - 'A' + 'a' == 'i') &&
                   (t[i] == 'L' || t[i] == 'l' || t[i] == 'i' || t[i] == 'I' ||
                    t[i] == '1'))
            continue;
          else
            break;
        } else if (s[i] == '1') {
          if (t[i] == 'L' || t[i] == 'l' || t[i] == 'i' || t[i] == 'I' ||
              t[i] == '1')
            continue;
          else
            break;
        } else if (s[i] == '0') {
          if (t[i] == '0' || t[i] == 'o' || t[i] == 'O')
            continue;
          else
            break;
        }
      }
      if (i == s.size()) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
