#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = -1e18;
const long long INF = 1e18;
long long bin_pow(long long n, long long k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  if (n == 0) return 0;
  if (k % 2 == 0) {
    long long t = bin_pow(n, k / 2);
    return (t * t);
  } else {
    return (bin_pow(n, k - 1) * n);
  }
}
bool isprime(long long x) {
  if (x == 1) return false;
  if (x == 2 || x == 3 || x == 5 || x == 7) return true;
  if (x % 2 == 0 || x % 3 == 0 || x % 5 == 0 || x % 7 == 0) return false;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long phi(long long n) {
  long long result = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      result -= result / i;
    }
  }
  if (n > 1) {
    result -= result / n;
  }
  return result;
}
string str, b;
long long n;
bool check(string b, string a) {
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '1' || a[i] == 'l' || a[i] == 'I' || a[i] == 'L' ||
        a[i] == 'i') {
      if (b[i] == '1' || b[i] == 'l' || b[i] == 'I' || b[i] == 'L' ||
          b[i] == 'i') {
        continue;
      }
    }
    if (a[i] == 'O' || a[i] == '0' || a[i] == 'o') {
      if (b[i] == 'O' || b[i] == '0' || b[i] == 'o') {
        continue;
      }
    }
    if (a[i] >= 'a' && a[i] <= 'z') {
      a[i] = char(a[i] - 32);
    }
    if (b[i] >= 'a' && b[i] <= 'z') {
      b[i] = char(b[i] - 32);
    }
    if (a[i] == b[i]) continue;
    return false;
  }
  return true;
}
int main() {
  cin >> str;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> b;
    if (b.size() != str.size()) continue;
    if (check(b, str) == true) {
      cout << "No";
      exit(false);
    }
  }
  cout << "Yes";
}
