#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, temp;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == 'o' || s[i] == 'O') s[i] = 'o';
    if (s[i] == '1' || s[i] == 'I' || s[i] == 'l' || s[i] == 'L' || s[i] == '1')
      s[i] = 'i';
    if (s[i] <= 'Z' && s[i] >= 'A')
      s[i] = (char)((int)s[i] + (int)'a' - (int)'A');
  }
  int n;
  cin >> n;
  for (int z = 0; z < n; z++) {
    cin >> temp;
    for (int i = 0; i < temp.size(); i++) {
      if (temp[i] == '0' || temp[i] == 'o' || temp[i] == 'O') temp[i] = 'o';
      if (temp[i] == '1' || temp[i] == 'I' || temp[i] == 'l' ||
          temp[i] == 'L' || temp[i] == '1')
        temp[i] = 'i';
      if (temp[i] <= 'Z' && temp[i] >= 'A')
        temp[i] = (char)((int)temp[i] + (int)'a' - (int)'A');
    }
    if (temp == s) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
