#include <bits/stdc++.h>
using namespace std;
int n, k;
string s, ss;
void make(string& str) {
  for (int i = 0; i < str.size(); i++) {
    if (str[i] >= 'A' && str[i] <= 'Z') str[i] = str[i] + 'a' - 'A';
    if (str[i] == 'i' || str[i] == 'l') str[i] = '1';
    if (str[i] == 'o' || str[i] == 'O') str[i] = '0';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  make(s);
  cin >> n;
  string g;
  for (int i = 0; i < n; i++) {
    cin >> g;
    if (s.size() != g.size()) continue;
    make(g);
    if (s == g) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
