#include <bits/stdc++.h>
using namespace std;
bool check(string s, long long n) {
  string t;
  long long i;
  cin >> t;
  if (t.size() != n) return 0;
  for (i = 0; i < n; i++) {
    if (s[i] == t[i]) continue;
    if ((('a' <= s[i] && 'z' >= s[i]) || ('A' <= s[i] && 'Z' >= s[i])) &&
        (('a' <= t[i] && 'z' >= t[i]) || ('A' <= t[i] && 'Z' >= t[i]))) {
      if (abs(s[i] - t[i]) == 32) continue;
    }
    if (s[i] == '0' && (t[i] == 'o' || t[i] == 'O')) continue;
    if (s[i] == 'o' && (t[i] == '0' || t[i] == 'O')) continue;
    if (s[i] == 'O' && (t[i] == 'o' || t[i] == '0')) continue;
    if (s[i] == '1' &&
        (t[i] == 'l' || t[i] == 'I' || t[i] == 'i' || t[i] == 'L'))
      continue;
    if (s[i] == 'l' && (t[i] == '1' || t[i] == 'I' || t[i] == 'i')) continue;
    if (s[i] == 'I' && (t[i] == 'l' || t[i] == '1' || t[i] == 'L')) continue;
    if (s[i] == 'i' && (t[i] == 'l' || t[i] == '1' || t[i] == 'L')) continue;
    if (s[i] == 'L' && (t[i] == 'i' || t[i] == '1' || t[i] == 'I')) continue;
    return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long n, k, ans = 0, m, j = 0, t = 0, x = 0, y = 0, c = 0, i, z = 0;
  string s;
  cin >> s >> n;
  k = s.size();
  while (n--) {
    if (check(s, k)) return cout << "No", 0;
    ;
  }
  cout << "Yes";
}
