#include <bits/stdc++.h>
using namespace std;
string arr;
int main() {
  cin >> arr;
  int f = 0;
  int n;
  cin >> n;
  for (int i = 0; i < arr.length(); i++) {
    if (arr[i] == 'I' || arr[i] == 'l' || arr[i] == 'L' || arr[i] == 'i')
      arr[i] = '1';
    if (arr[i] >= 'A' && arr[i] <= 'Z') arr[i] += 32;
    if (arr[i] == '0') arr[i] = 'o';
  }
  while (n--) {
    string brr;
    cin >> brr;
    for (int i = 0; i < brr.length(); i++) {
      if (brr[i] == 'I' || brr[i] == 'l' || brr[i] == 'L' || brr[i] == 'i')
        brr[i] = '1';
      if (brr[i] >= 'A' && brr[i] <= 'Z') brr[i] += 32;
      if (brr[i] == '0') brr[i] = 'o';
    }
    if (arr == brr) f = 1;
  }
  if (f)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
