#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  std::string str;
  std::cin >> str;
  for (int i = 0; i < str.size(); ++i) {
    str[i] = tolower(str[i]);
    if (str[i] == '0') str[i] = 'o';
    if (str[i] == 'l' || str[i] == '1') str[i] = 'i';
  }
  int s;
  std::cin >> s;
  std::vector<std::string> v(s);
  for (int i = 0; i < s; ++i) {
    std::cin >> v[i];
    for (int j = 0; j < v[i].size(); ++j) {
      v[i][j] = tolower(v[i][j]);
      if (v[i][j] == '0') v[i][j] = 'o';
      if (v[i][j] == 'l' || v[i][j] == '1') v[i][j] = 'i';
    }
  }
  for (int i = 0; i < s; ++i) {
    if (str == v[i]) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
