#include <bits/stdc++.h>
int main() {
  int n, i, j;
  int flg = 1;
  char str1[200], str2[200];
  scanf("%s", str1);
  scanf("%d", &n);
  for (i = 0; i < strlen(str1); i++) {
    if (str1[i] >= 'A' && str1[i] <= 'Z') str1[i] += 32;
    if (str1[i] == 'o' || str1[i] == '0') str1[i] = '0';
    if (str1[i] == 'l' || str1[i] == 'i' || str1[i] == 'L' || str1[i] == 'I')
      str1[i] = '1';
  }
  for (i = 0; i < n; i++) {
    scanf("%s", str2);
    for (j = 0; str2[j]; j++) {
      if (str2[j] >= 'A' && str2[j] <= 'Z') str2[j] += 32;
      if (str2[j] == 'o' || str2[j] == '0') str2[j] = '0';
      if (str2[j] == 'l' || str2[j] == 'i' || str2[j] == 'L' || str2[j] == 'I')
        str2[j] = '1';
    }
    if (strcmp(str1, str2) == 0) flg = 0;
  }
  if (flg) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}
