#include <bits/stdc++.h>
using namespace std;
string mainLogin;
vector<string> existLogins;
int n;
void inp() {
  cin >> mainLogin;
  cin >> n;
  existLogins.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> existLogins[i];
  }
}
bool check(const string &toCheck) {
  if (toCheck.size() != mainLogin.size()) return false;
  for (int i = 0; i < toCheck.size(); i++) {
    const char &ch = toCheck[i];
    if (isdigit(ch)) {
      if (ch == '0') {
        if (mainLogin[i] != 'O' && mainLogin[i] != 'o' && mainLogin[i] != '0')
          return false;
        continue;
      }
      if (ch == '1') {
        if (mainLogin[i] != 'l' && mainLogin[i] != 'I' && mainLogin[i] != 'L' &&
            mainLogin[i] != 'i' && mainLogin[i] != '1')
          return false;
        continue;
      }
    }
    if (isalpha(ch)) {
      if (ch == 'O' || ch == 'o') {
        if (mainLogin[i] != '0' && mainLogin[i] != 'O' && mainLogin[i] != 'o')
          return false;
        continue;
      }
      if (ch == 'l' || ch == 'L') {
        if (mainLogin[i] != '1' && mainLogin[i] != 'I' && mainLogin[i] != 'L' &&
            mainLogin[i] != 'i' && mainLogin[i] != 'l')
          return false;
        continue;
      }
      if (ch == 'I' || ch == 'i') {
        if (mainLogin[i] != '1' && mainLogin[i] != 'l' && mainLogin[i] != 'i' &&
            mainLogin[i] != 'L' && mainLogin[i] != 'I')
          return false;
        continue;
      }
      if (isupper(ch) && islower(mainLogin[i])) {
        if (mainLogin[i] != tolower(ch)) return false;
        continue;
      }
      if (islower(ch) && isupper(mainLogin[i])) {
        if (mainLogin[i] != toupper(ch)) return false;
        continue;
      }
    }
    if (ch != mainLogin[i]) return false;
  }
  return true;
}
void solve() {
  for (int i = 0; i < n; i++) {
    if (check(existLogins[i])) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  inp();
  solve();
  return 0;
}
