#include <bits/stdc++.h>
using namespace std;
int main() {
  string login;
  cin >> login;
  transform(login.begin(), login.end(), login.begin(),
            (int (*)(int))std::toupper);
  int n;
  cin >> n;
  vector<string> logins(n);
  for (int i = 0; i < n; ++i) cin >> logins[i];
  bool canReg = true;
  for (int i = 0; i < n; i++) {
    if (logins[i].size() != login.size()) continue;
    for (int j = 0; j < logins[i].size(); j++) {
      logins[i][j] = char(toupper(logins[i][j]));
      if ((login[j] == '1' || login[j] == 'L' || login[j] == 'I') &&
          (logins[i][j] == '1' || logins[i][j] == 'L' || logins[i][j] == 'I')) {
        logins[i][j] = login[j];
      }
      if ((login[j] == 'O' || login[j] == '0') &&
          (logins[i][j] == 'O' || logins[i][j] == '0')) {
        logins[i][j] = login[j];
      }
    }
    if (logins[i] == login) {
      canReg = false;
      break;
    }
  }
  if (canReg)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
