#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
enum { MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009 };
template <typename T>
ostream &operator<<(ostream &cout, vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) cout << a[i] << " ";
  return cout;
}
template <typename T>
ostream &operator<<(ostream &cout, vector<vector<T> > &a) {
  for (size_t i = 0; i < a.size(); ++i) cout << a[i] << endl;
  return cout;
}
int p[256];
inline bool eq(int a, int b) { return p[a] == p[b]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  for (int i = 0; i < sizeof(p) / sizeof(*p); ++i) {
    p[i] = i;
  }
  p['1'] = p['i'] = p['l'];
  p['0'] = p['o'];
  for (int i = 'A'; i <= 'Z'; ++i) {
    p[i] = p[i - 'A' + 'a'];
  }
  string s;
  cin >> s;
  int n;
  cin >> n;
  string a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a.size() != s.size()) {
      continue;
    }
    bool bad = 1;
    for (int j = 0; j < a.size(); ++j) {
      if (!eq(a[j], s[j])) {
        bad = 0;
        break;
      }
    }
    if (bad) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}
