#include <bits/stdc++.h>
using namespace std;
void f(string &s) {
  for (auto &c : s) {
    c = static_cast<char>(tolower(c));
    if (c == 'i') {
      c = '1';
    } else if (c == 'l') {
      c = '1';
    } else if (c == 'o') {
      c = '0';
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int n;
  cin >> s;
  f(s);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s1;
    cin >> s1;
    f(s1);
    if (s == s1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
