#include <bits/stdc++.h>
using namespace std;
string make(string a) {
  for (int i = 0; i < a.size(); i++) {
    if ((a[i] >= 'A') && (a[i] <= 'Z')) {
      a[i] = a[i] - 'A' + 'a';
    }
    if (a[i] == 'o') {
      a[i] = '0';
    }
    if ((a[i] == 'l') || (a[i] == 'i')) {
      a[i] = '1';
    }
  }
  return a;
}
string a[1111];
int main() {
  string ans;
  cin >> ans;
  ans = make(ans);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = make(a[i]);
    if (a[i] == ans) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
