#include <bits/stdc++.h>
using namespace std;
void flash() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
vector<long long int> parent(1024);
void build(long long int v) { parent[v] = v; }
long long int find_set(long long int v) {
  if (parent[v] == v) return v;
  return parent[v] = find_set(parent[v]);
}
void union_sets(long long int a, long long int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) parent[a] = b;
}
set<char> badl;
bool isEqual(string p1, string p2) {
  if (p1.size() != p2.size()) return false;
  for (long long int i = 0; i < min(p1.size(), p2.size()); i++) {
    if (find_set(p1[i]) == find_set(p2[i])) continue;
    return false;
  }
  return true;
}
signed main() {
  for (char c = 'a'; c <= 'z'; c++) build((long long int)c);
  for (char c = 'A'; c <= 'Z'; c++) build((long long int)c);
  for (char c = '1'; c <= '9'; c++) build((long long int)c);
  build('_');
  for (char i = 'a'; i <= 'z'; i++) {
    union_sets((long long int)i,
               (long long int)i - (long long int)'a' + (long long int)'A');
  }
  union_sets((long long int)'l', (long long int)'i');
  union_sets((long long int)'1', (long long int)'i');
  union_sets((long long int)'0', (long long int)'O');
  string password;
  cin >> password;
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (isEqual(s, password)) return cout << "No" << '\n', 0;
  }
  cout << "Yes" << '\n';
  return 0;
}
