#include <bits/stdc++.h>
using namespace std;
bool pohozhi(string s1, string s2) {
  if (s1.size() != s2.size()) {
    return false;
  }
  for (int i = 0; i < s1.size(); ++i) {
    s1[i] = toupper(s1[i]);
    if (s1[i] == 'O') {
      s1[i] = '0';
    }
    if (s1[i] == 'I' || s1[i] == 'L') {
      s1[i] = '1';
    }
    s2[i] = toupper(s2[i]);
    if (s2[i] == 'O') {
      s2[i] = '0';
    }
    if (s2[i] == 'I' || s2[i] == 'L') {
      s2[i] = '1';
    }
    if (s1[i] != s2[i]) {
      return false;
    }
  }
  return true;
}
int main() {
  string s1, s2;
  cin >> s1;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s2;
    if (pohozhi(s1, s2)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
