#include <bits/stdc++.h>
const long long P = 51;
using namespace std;
string s, p;
int n;
bool check(string p) {
  int cnt = 0;
  for (int i = 0; i < p.size(); i++) {
    char a = p[i];
    char b = s[i];
    if (a == '0') a = 'O';
    if (b == '0') b = 'O';
    if (toupper(a) == toupper(b)) {
      cnt++;
      continue;
    }
    if (a == '1') a = 'l';
    if (b == '1') b = 'l';
    a = toupper(a);
    b = toupper(b);
    if (a == b || (a == 'L' && b == 'I') || (a == 'I' && b == 'L')) cnt++;
  }
  return cnt == p.size();
}
int main() {
  cin >> s >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p;
    if (p.size() != s.size()) continue;
    if (check(p)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
