#include <bits/stdc++.h>
using namespace std;
template <class htpe, class cmp>
using heap = priority_queue<htpe, vector<htpe>, cmp>;
template <class htpe>
using min_heap = heap<htpe, greater<htpe> >;
template <class htpe>
using max_heap = heap<htpe, less<htpe> >;
const int INF = 1791791791;
const long long INFLL = 1791791791791791791ll;
int num_l(char c) {
  if ('0' <= c && c <= '9') return c - '0';
  if ('a' <= c && c <= 'z') return c - 'a' + 10;
  if ('A' <= c && c <= 'Z') return c - 'A' + 36;
  return 36 + 26;
}
const int numl = 36 + 27;
int numc[numl];
void unite(char a, char b) {
  int onc = numc[num_l(b)];
  for (int i = 0; i < ((int)(numl)); ++i) {
    if (numc[i] == onc) numc[i] = numc[num_l(a)];
  }
}
bool similar_letters(char a, char b) {
  return numc[num_l(a)] == numc[num_l(b)];
}
bool similar_strings(string s, string t) {
  if (s.size() != t.size()) return false;
  for (int i = 0; i < ((int)(s.size())); ++i) {
    if (!similar_letters(s[i], t[i])) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  iota(numc, numc + numl, 0);
  for (int i = 0; i < ((int)(26)); ++i) unite('a' + i, 'A' + i);
  unite('o', '0');
  unite('1', 'l');
  unite('1', 'I');
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < ((int)(n)); ++i) {
    string t;
    cin >> t;
    if (similar_strings(s, t)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
