#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
const double pi = acos(-1.0);
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void stand(string &s) {
  for (int i = 0; i < ((int)s.size()); i++) {
    if (isupper(s[i])) s[i] += 32;
    if (s[i] == 'o')
      s[i] = '0';
    else if (s[i] == 'l' || s[i] == 'i')
      s[i] = '1';
  }
}
bool check(string s, string t) {
  for (int i = 0; i < ((int)s.size()); i++)
    if (s[i] != t[i]) return false;
  return true;
}
bool solve() {
  string s, t;
  int q;
  cin >> s >> q;
  stand(s);
  for (int i = 1; i <= q; i++) {
    cin >> t;
    stand(t);
    if (((int)s.size()) != ((int)t.size())) continue;
    if (check(s, t)) return false;
  }
  return true;
}
int main() {
  if (solve())
    puts("Yes");
  else
    puts("No");
  return 0;
}
