#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1;
  int n;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] < 91 && s[i] > 64) s[i] = s[i] + 32;
    if (s[i] == '0') s[i] = 'o';
    if (s[i] == '1') s[i] = 'l';
    if (s[i] == 'i') s[i] = 'l';
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1;
    if (s.length() == s1.length()) {
      for (int j = 0; j < s1.length(); j++) {
        if (s1[j] < 91 && s1[j] > 64) s1[j] = s1[j] + 32;
        if (s1[j] == '0') s1[j] = 'o';
        if (s1[j] == '1') s1[j] = 'l';
        if (s1[j] == 'i') s1[j] = 'l';
      }
      if (s == s1) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
  return 0;
}
