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