#include <bits/stdc++.h>
const int N = 100500;
const int INF = 1000000000;
const long long MOD = 1e9 + 7;
const long long p1 = 1987;
using namespace std;
int n, m, a[N], sz;
string s, ss;
bool ok1, ok2;
bool check(int x) {
  if (s[x] == '1' || s[x] == 'l' || s[x] == 'L' || s[x] == 'I' || s[x] == 'i')
    ok1 = true;
  if (s[x] == '0' || s[x] == 'o' || s[x] == 'O') ok2 = true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ss;
    if (ss.size() != s.size()) continue;
    for (int j = 0; j < s.size(); j++) {
      check(j);
      if ((ss[j] == s[j] + 32 || ss[j] == s[j] - 32 || s[j] == ss[j]))
        sz++;
      else if (ok1) {
        if (ss[j] == '1' || ss[j] == 'l' || ss[j] == 'L' || ss[j] == 'I' ||
            ss[j] == 'i')
          sz++;
      } else if (ok2) {
        if (ss[j] == '0' || ss[j] == 'O' || ss[j] == 'o') sz++;
      }
      ok1 = false;
      ok2 = false;
    }
    cerr << sz;
    if (sz == s.size()) cout << "No", exit(0);
    sz = 0;
  }
  cout << "Yes";
  return 0;
}
