#include <bits/stdc++.h>
using namespace std;
void convert(string &str) {
  int len = str.length();
  for (int i = 0; i < len; ++i) {
    if (str[i] == 'l' || str[i] == 'I' || str[i] == 'L' || str[i] == 'i')
      str[i] = '1';
    else if (str[i] == 'O' || str[i] == 'o')
      str[i] = '0';
    if (str[i] >= 'A' && str[i] <= 'Z') str[i] = 'a' + str[i] - 'A';
  }
}
int main() {
  string word;
  cin >> word;
  convert(word);
  int n;
  cin >> n;
  string example;
  bool found = false;
  for (int i = 0; i < n && !found; i++) {
    cin >> example;
    convert(example);
    found = example == word;
  }
  if (found)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
