#include <bits/stdc++.h>
using namespace std;
string s;
int n;
map<string, bool> used;
int main() {
  cin >> s >> n;
  for (int j = 0; j < s.size(); j++) {
    s[j] = tolower(s[j]);
    if (s[j] == 'i' || s[j] == 'l')
      s[j] = '1';
    else if (s[j] == 'o')
      s[j] = '0';
  }
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    for (int j = 0; j < a.size(); j++) {
      a[j] = tolower(a[j]);
      if (a[j] == 'i' || a[j] == 'l')
        a[j] = '1';
      else if (a[j] == 'o')
        a[j] = '0';
    }
    used[a] = true;
  }
  if (used[s] == true)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
