#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const int N = (int)2e6 + 7, MOD = (int)1e9 + 7;
string second;
int n;
map<string, int> m;
string pro(string x) {
  string second = x;
  for (int i = 0; i < x.size(); i++) {
    if (second[i] >= 'A' && second[i] <= 'Z') {
      second[i] += 32;
    }
  }
  for (int i = 0; i < x.size(); i++) {
    if (second[i] == 'o') {
      second[i] = '0';
    }
  }
  for (int i = 0; i < x.size(); i++) {
    if (second[i] == 'l' || second[i] == 'i') {
      second[i] = '1';
    }
  }
  return second;
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> second;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string x, y;
    cin >> x;
    y = pro(x);
    m[y] = 1;
  }
  string a = pro(second);
  if (m[a] == 1) {
    cout << "No"
         << "\n";
  } else
    cout << "Yes"
         << "\n";
  exit(0);
}
