#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string t;
  cin >> t;
  int n;
  cin >> n;
  map<string, bool> ss;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.length(); j++) {
      if ('A' <= s[j] && s[j] <= 'Z') {
        s[j] = 'a' + (s[j] - 'A');
      }
      if (s[j] == '0') s[j] = 'o';
      if (s[j] == 'i' || s[j] == 'l') s[j] = '1';
    }
    ss[s] = true;
  }
  string s = t;
  for (int j = 0; j < s.length(); j++) {
    if ('A' <= s[j] && s[j] <= 'Z') {
      s[j] = 'a' + (s[j] - 'A');
    }
    if (s[j] == '0') s[j] = 'o';
    if (s[j] == 'i' || s[j] == 'l') s[j] = '1';
  }
  if (ss[s] == true)
    cout << "No";
  else
    cout << "Yes";
}
