#include <bits/stdc++.h>
using namespace std;
string first(string second) {
  for (long long i = 0; i < second.size(); i++) {
    if (second[i] >= 'A' && second[i] <= 'Z') {
      second[i] = second[i] + 32;
    }
    if (second[i] == '0') {
      second[i] = 'o';
    }
    if (second[i] == 'l' || second[i] == 'i') {
      second[i] = '1';
    }
  }
  return second;
}
int main() {
  string second;
  cin >> second;
  second = first(second);
  long long n;
  scanf("%lld", &n);
  vector<string> v;
  string t;
  for (long long i = 0; i < n; i++) {
    cin >> t;
    v.push_back(t);
  }
  for (long long i = 0; i < n; i++) {
    t = first(v[i]);
    if (second == t) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}
