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