#include <bits/stdc++.h>
using namespace std;
bool match(char a, char b) {
  if (a >= 'a') a = a - 'a' + 'A';
  if (b >= 'a') b = b - 'a' + 'A';
  if ((a == '0' || a == 'o' || a == 'O') && (b == '0' || b == 'o' || b == 'O'))
    return true;
  if ((a == '1' || a == 'L' || a == 'I') && (b == '1' || b == 'L' || b == 'I'))
    return true;
  return a == b;
}
string s, t[1010];
long long n;
int main() {
  cin >> s;
  cin >> n;
  long long len = s.size();
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> t[i];
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    bool dame = true;
    if (len != t[i].size()) continue;
    for (long long j = (long long)(0); j < (long long)(len); j++) {
      if (!match(s[j], t[i][j])) dame = false;
    }
    if (dame) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
