#include <bits/stdc++.h>
using namespace std;
char upr(char a) {
  char ans = a;
  long long in = int(ans);
  if ((in >= 65) && (in <= 90)) ans = char(in + 32);
  if (ans == '0') ans = 'o';
  if ((ans == 'l') || (ans == 'i')) ans = '1';
  return ans;
}
int main() {
  string s;
  cin >> s;
  long long n;
  cin >> n;
  string c[n];
  for (long long i = 0; i < n; i++) cin >> c[i];
  bool f = 0;
  for (long long i = 0; i < n; i++) {
    bool fi = 0;
    if (s.size() == c[i].size()) {
      for (long long j = 0; j < s.size(); j++) {
        if (upr(s[j]) != upr(c[i][j])) fi = 1;
      }
    } else
      fi = 1;
    if (fi == 0) f = 1;
  }
  if (f == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
