#include <bits/stdc++.h>
using namespace std;
bool foo(string a, string b) {
  unsigned long long int i;
  for (i = 0; i < a.size(); ++i) {
    if (tolower(a[i]) == tolower(b[i]) || a[i] == '0' && tolower(b[i]) == 'o' ||
        tolower(a[i]) == 'o' && b[i] == '0' ||
        a[i] == '1' && tolower(b[i]) == 'l' ||
        a[i] == '1' && toupper(b[i]) == 'I' ||
        b[i] == '1' && tolower(a[i]) == 'l' ||
        b[i] == '1' && toupper(a[i]) == 'I' ||
        tolower(a[i]) == 'l' && toupper(b[i]) == 'I' ||
        tolower(b[i]) == 'l' && toupper(a[i]) == 'I') {
    } else
      return false;
  }
  return true;
}
int main() {
  unsigned long long int n, i;
  string qwe, temp;
  cin >> qwe >> n;
  for (i = 0; i < n; ++i) {
    cin >> temp;
    if (temp.size() == qwe.size())
      if (foo(qwe, temp)) {
        cout << "No";
        return 0;
      }
  }
  cout << "Yes";
  return 0;
}
