#include <bits/stdc++.h>
using namespace std;
string go(string s) {
  for (auto &u : s) {
    if (u == 'o' || u == 'O')
      u = '0';
    else if (u == 'i' || u == 'I' || u == 'L' || u == 'l')
      u = '1';
  }
  for (auto &u : s) {
    if (u >= 'A' && u <= 'Z') u = u - 'A' + 'a';
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  s = go(s);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    t = go(t);
    if (s == t) {
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
}
