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