#include <bits/stdc++.h>
using namespace std;
long long i, j, n;
string p, q, s, a[1000009];
char c;
int main() {
  cin >> s;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < s.length(); i++) {
    c = tolower(s[i]);
    if (c == 'o') c = '0';
    if (c == 'i' || c == 'l') c = '1';
    q += c;
  }
  for (i = 1; i <= n; i++) {
    if (a[i].length() != s.length()) continue;
    p = "";
    for (j = 0; j < s.length(); j++) {
      c = tolower(a[i][j]);
      if (c == 'o') c = '0';
      if (c == 'i' || c == 'l') c = '1';
      p += c;
    }
    if (p == q) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
