#include <bits/stdc++.h>
using namespace std;
string str;
int n;
string buf;
void PreProc() {}
void Vvod() {
  cin >> str >> n;
  for (int i = 0; i < n; i++) {
    cin >> buf;
    if (str.length() != buf.length()) continue;
    bool e = false;
    for (int j = 0; j < str.length(); j++) {
      if (str[j] == buf[j]) continue;
      if ((str[j] == '1' || str[j] == 'l' || str[j] == 'i' || str[j] == 'L' ||
           str[j] == 'I') &&
          (buf[j] == '1' || buf[j] == 'l' || buf[j] == 'i' || buf[j] == 'L' ||
           buf[j] == 'I'))
        continue;
      if ((str[j] == 'O' || str[j] == '0' || str[j] == 'o') &&
          (buf[j] == 'O' || buf[j] == '0' || buf[j] == 'o'))
        continue;
      if (toupper(str[j]) == toupper(buf[j])) continue;
      e = true;
      break;
    }
    if (e) continue;
    cout << "No";
    return;
  }
  cout << "Yes";
}
void Solve() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  PreProc();
  Vvod();
  Solve();
  return 0;
}
