#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h, i, j, t, m, l, r, q;
  long long p = 0, k, w, z, x, y, d;
  q = 1;
  for (l = 0; l < q; l++) {
    string s;
    std::cin >> s;
    k = s.length();
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    std::cin >> n;
    string a[n];
    x = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      m = a[i].length();
      if (m == k && x == 0) {
        transform(a[i].begin(), a[i].end(), a[i].begin(), ::tolower);
        for (j = 0; j < m; j++) {
          if (s[j] != a[i][j]) {
            if ((s[j] == '0' && a[i][j] == 'O') ||
                (a[i][j] == 'o' && s[j] == '0'))
              continue;
            else if ((s[j] == 'O' && a[i][j] == '0') ||
                     (a[i][j] == '0' && s[j] == 'o'))
              continue;
            else if (s[j] == '1' && (a[i][j] == 'l' || a[i][j] == 'i' ||
                                     a[i][j] == 'L' || a[i][j] == 'I'))
              continue;
            else if ((s[j] == 'I' || s[j] == 'i') &&
                     (a[i][j] == 'l' || a[i][j] == 'L' || a[i][j] == '1'))
              continue;
            else if ((s[j] == 'l' || s[j] == 'L') &&
                     (a[i][j] == '1' || a[i][j] == 'I' || a[i][j] == 'i'))
              continue;
            else
              break;
          }
        }
        if (j == m) x = 1;
      }
    }
    if (x == 0)
      std::cout << "YES" << std::endl;
    else
      std::cout << "NO" << std::endl;
  }
  return 0;
}
