#include <bits/stdc++.h>
using namespace std;
bool check(string new_l, string old_l) {
  int len_1;
  int col_izm;
  col_izm = 0;
  len_1 = new_l.length();
  if (len_1 == old_l.length()) {
    for (int i = 0; i < len_1; i++) {
      if (new_l[i] == old_l[i]) {
        col_izm++;
      } else if (((new_l[i] == '1') || (new_l[i] == 'i') || (new_l[i] == 'l') ||
                  (new_l[i] == 'I') || (new_l[i] == 'L')) &&
                 ((old_l[i] == '1') || (old_l[i] == 'i') || (old_l[i] == 'l') ||
                  (old_l[i] == 'I') || (old_l[i] == 'L'))) {
        col_izm++;
      } else if (((new_l[i] == '0') || (new_l[i] == 'o') ||
                  (new_l[i] == 'O')) &&
                 ((old_l[i] == '0') || (old_l[i] == 'o') ||
                  (old_l[i] == 'O'))) {
        col_izm++;
      } else if (((new_l[i] - old_l[i]) == 32) ||
                 ((new_l[i] - old_l[i]) == -32)) {
        col_izm++;
      } else
        return true;
    }
    if (col_izm == len_1)
      return false;
    else
      return true;
  } else
    return true;
}
int main() {
  string n_login, login;
  int col;
  cin >> n_login;
  cin >> col;
  for (int i = 0; i < col; i++) {
    cin >> login;
    if (!check(n_login, login)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
