#include <bits/stdc++.h>
using namespace std;
void Unificate(string& login) {
  for (auto& c : login) {
    if (c == 'O' or c == 'o') {
      c = '0';
    } else if (c == 'I' or c == 'i' or c == 'l' or c == 'L') {
      c = '1';
    }
  }
  for (auto& c : login) {
    if (isalpha(c)) {
      c = tolower(c);
    }
  }
}
int main() {
  string new_login;
  cin >> new_login;
  Unificate(new_login);
  int n;
  cin >> n;
  set<string> logins;
  for (int i = 0; i < n; ++i) {
    string login;
    cin >> login;
    Unificate(login);
    logins.insert(login);
  }
  if (logins.find(new_login) == logins.end()) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}
