#include <bits/stdc++.h>
char ToUnischar(char ch) {
  ch = ::tolower(ch);
  switch (ch) {
    case 'i':
      return '1';
    case 'l':
      return '1';
    case 'o':
      return '0';
    default:
      return ch;
  }
}
void ToUnistring(std::string& data) {
  std::transform(data.begin(), data.end(), data.begin(), ToUnischar);
}
int main() {
  std::string loginCandidate;
  int loginsCount = 0;
  std::cin >> loginCandidate;
  std::cin >> loginsCount;
  ToUnistring(loginCandidate);
  for (int i = 0; i < loginsCount; i++) {
    std::string login;
    std::cin >> login;
    ToUnistring(login);
    if (login == loginCandidate) {
      std::cout << "No";
      return 0;
    }
  }
  std::cout << "Yes";
  return 0;
}
