#include <bits/stdc++.h>
int main() {
  char str1[51], str2[51];
  int flag1 = 0, flag2 = 0, x;
  scanf("%s", str1);
  scanf("%d", &x);
  int arr[x];
  for (int j = 0; j < x; j++) {
    scanf("%s", str2);
    for (int i = 0; i < strlen(str1); i++) {
      int ch1 = str1[i], ch2 = str2[i];
      if (strlen(str1) != strlen(str2)) {
        flag2 = 1;
      } else if (str1[i] == '0' || str1[i] == 'o' || str1[i] == 'O') {
        if (str2[i] == '0' || str2[i] == 'o' || str2[i] == 'O') {
          continue;
        } else {
          flag2 = 1;
        }
      } else if (str1[i] == '1' || str1[i] == 'l' || str1[i] == 'L' ||
                 str1[i] == 'i' || str1[i] == 'I') {
        if (str2[i] == '1' || str2[i] == 'l' || str2[i] == 'L' ||
            str2[i] == 'i' || str2[i] == 'I') {
          continue;
        } else {
          flag2 = 1;
        }
      } else if (ch1 == ch2) {
        continue;
      } else if (ch1 >= 65 && ch1 <= 90 || ch1 >= 97 && ch1 <= 122) {
        if (ch1 - ch2 == 32 || ch1 - ch2 == 0 || ch1 - ch2 == -32) {
          continue;
        } else {
          flag2 = 1;
        }
      }
    }
    arr[j] = flag2;
    flag2 = 0;
  }
  for (int l = 0; l < x; l++) {
    if (arr[l] == 0) {
      flag1 = 1;
      break;
    } else {
      continue;
    }
  }
  if (flag1 == 1) {
    printf("No");
  } else {
    printf("Yes");
  }
}
