#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o' || s[i] == 'O') {
      s[i] = '0';
    }
    if (s[i] == 'l' || s[i] == 'L' || s[i] == 'i' || s[i] == 'I') {
      s[i] = '1';
    }
    s[i] = tolower(s[i]);
  }
  for (int i = 0; i < n; i++) {
    string s1;
    cin >> s1;
    for (int i = 0; i < s1.size(); i++) {
      if (s1[i] == 'o' || s1[i] == 'O') {
        s1[i] = '0';
      }
      if (s1[i] == 'l' || s1[i] == 'L' || s1[i] == 'i' || s1[i] == 'I') {
        s1[i] = '1';
      }
      s1[i] = tolower(s1[i]);
    }
    if (s1 == s) {
      cout << "No";
      exit(0);
    }
  }
  cout << "Yes";
}
