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