#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  string s, x;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    s[i] = tolower(s[i]);
    if (s[i] == 'o') s[i] = '0';
    if (s[i] == 'l') s[i] = '1';
    if (s[i] == 'i') s[i] = '1';
  }
  int n, flag = 0;
  cin >> n;
  while (n--) {
    cin >> x;
    for (int i = 0; i < x.size(); i++) {
      x[i] = tolower(x[i]);
      if (x[i] == 'o') x[i] = '0';
      if (x[i] == 'l') x[i] = '1';
      if (x[i] == 'i') x[i] = '1';
    }
    if (x == s) {
      flag = 1;
      break;
    }
  }
  if (flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
