#include <bits/stdc++.h>
using namespace std;
void solve() {
  string a;
  cin >> a;
  transform((a).begin(), (a).end(), a.begin(), ::tolower);
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == 'o') a[i] = '0';
    if (a[i] == 'i' || a[i] == 'l') a[i] = '1';
  }
  int n;
  cin >> n;
  string b[n];
  for (int j = 0; j < n; j++) {
    cin >> b[j];
    transform((b[j]).begin(), (b[j]).end(), b[j].begin(), ::tolower);
    for (int i = 0; i < b[j].length(); i++) {
      if (b[j][i] == 'o') b[j][i] = '0';
      if (b[j][i] == 'i' || b[j][i] == 'l') b[j][i] = '1';
    }
    if (a == b[j]) {
      cout << "No";
      return;
    }
  }
  cout << "Yes";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  int count = 1;
loop:
  while (t--) {
    solve();
    count++;
  }
}
