#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  transform(s.begin(), s.end(), s.begin(), ::tolower);
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'o')
      s[i] = '0';
    else if (s[i] == 'i')
      s[i] = '1';
    else if (s[i] == 'l')
      s[i] = '1';
  }
  int n;
  cin >> n;
  string a[n];
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    transform(t.begin(), t.end(), t.begin(), ::tolower);
    for (int j = 0; j < t.length(); j++) {
      if (t[j] == 'o')
        t[j] = '0';
      else if (t[j] == 'i')
        t[j] = '1';
      else if (t[j] == 'l')
        t[j] = '1';
    }
    a[i] = t;
  }
  int flag = 0;
  for (int i = 0; i < n; i++) {
    if (s == a[i]) {
      cout << "NO";
      flag = 1;
      break;
    }
  }
  if (flag == 0) cout << "YES";
  return 0;
}
