#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long inf = 1e18;
long long mx = -1;
long long mn = 1e18;
long long calpow(long long a, long long b, long long md) {
  long long mul = 1;
  while (b > 0) {
    if (b & 1) {
      mul = ((a % md) * (mul % md)) % md;
      b--;
    } else {
      a = ((a % md) * (a % md)) % md;
      b /= 2;
    }
  }
  return mul;
}
void solve() {
  long long i, j, n, t, q, a, b, m, k, ct = 0, sum = 0, flag = 0;
  string s;
  cin >> s;
  cin >> n;
  while (n--) {
    string s1;
    cin >> s1;
    if (s1.size() != s.size()) continue;
    j = s.size();
    ct = 0;
    for (long long i = (0); i < (j); i++) {
      if (s[i] == s1[i])
        ct++;
      else {
        if (s[i] == '0' || s[i] == 'o' || s[i] == 'O') {
          if (s1[i] == '0' || s1[i] == 'o' || s1[i] == 'O') ct++;
        } else if (s[i] == '1' || s[i] == 'I' || s[i] == 'i' || s[i] == 'L' ||
                   s[i] == 'l') {
          if (s1[i] == '1' || s1[i] == 'I' || s1[i] == 'i' || s1[i] == 'L' ||
              s1[i] == 'l')
            ct++;
        } else {
          m = s[i];
          k = s1[i];
          char c = s[i], d = s1[i];
          if (m >= 65 && m < 97) {
            m += 32;
            c = m;
          }
          if (k >= 65 && k < 97) {
            k += 32;
            d = k;
          }
          if (c == d) ct++;
        }
      }
    }
    if (ct == j) {
      cout << "No";
      return;
    }
  }
  cout << "Yes";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  cerr << endl << clock() * 1000.0 / CLOCKS_PER_SEC << 'm' << 's';
  return 0;
}
