#include <bits/stdc++.h>
using namespace std;
const int r = abs('A' - 'a');
const set<char> s1{'1', 'l', 'L', 'I', 'i'}, s2{'0', 'o', 'O'};
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string ss;
    cin >> ss;
    if (ss.size() != s.size()) continue;
    bool b = true;
    for (int j = 0; j < ss.size(); j++) {
      if (ss[j] == s[j]) continue;
      if (abs(ss[j] - s[j]) == r) continue;
      if (s1.find(ss[j]) == s1.end() && s1.find(s[j]) == s1.end() &&
          s2.find(ss[j]) == s2.end() && s2.find(s[j]) == s2.end()) {
        b = false;
        break;
      }
      if (s1.find(ss[j]) != s1.end() && s1.find(s[j]) != s1.end()) continue;
      if (s1.find(ss[j]) != s1.end() && s1.find(s[j]) != s1.end()) continue;
      if (s1.find(ss[j]) != s1.end() && s1.find(s[j]) == s1.end()) {
        b = false;
        break;
      }
      if (s2.find(ss[j]) != s2.end() && s2.find(s[j]) == s2.end()) {
        b = false;
        break;
      }
      if (s1.find(s[j]) != s1.end() && s1.find(ss[j]) == s1.end()) {
        b = false;
        break;
      }
      if (s2.find(s[j]) != s2.end() && s2.find(ss[j]) == s2.end()) {
        b = false;
        break;
      }
    }
    if (b) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
