#include <bits/stdc++.h>
using namespace std;
int a, s, d, f, g, h, j, k, l, i, n, m;
string x, z;
int main() {
  cin >> x >> n;
  for (i = 0; i < x.size(); i++) {
    if (x[i] >= 'A' && x[i] <= 'Z') x[i] += 32;
    if (x[i] == '0') x[i] = 'o';
    if (x[i] == '1') x[i] = 'i';
    if (x[i] == 'l') x[i] = 'i';
  }
  for (i = 0; i < n; i++) {
    cin >> z;
    for (int i = 0; i < z.size(); i++) {
      if (z[i] >= 'A' && z[i] <= 'Z') z[i] += 32;
      if (z[i] == '0') z[i] = 'o';
      if (z[i] == '1') z[i] = 'i';
      if (z[i] == 'l') z[i] = 'i';
    }
    if (z == x) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
