#include <bits/stdc++.h>
int main() {
  char s1[60], s2[60];
  int i, j, n, len1, len2, flag = 0, f;
  scanf("%s %d", s1, &n);
  len1 = strlen(s1);
  for (i = 0; i < n; i++) {
    f = 0;
    scanf("%s", s2);
    len2 = strlen(s2);
    if (len1 == len2 && flag == 0) {
      for (j = 0; j < len1; j++) {
        if ((s1[j] == 'L' || s1[j] == 'i' || s1[j] == '1') &&
            (s2[j] == 'L' || s2[j] == '1' || s2[j] == 'i')) {
          continue;
        }
        s1[j] = tolower(s1[j]);
        s2[j] = tolower(s2[j]);
        if (s1[j] != s2[j]) {
          if ((s1[j] == 'o' || s1[j] == '0') &&
              (s2[j] == 'o' || s2[j] == '0')) {
            continue;
          } else if ((s1[j] == 'l' || s1[j] == 'i' || s1[j] == '1') &&
                     (s2[j] == 'l' || s2[j] == '1' || s2[j] == 'i')) {
            continue;
          } else {
            f = 1;
            break;
          }
        }
      }
      if (f == 0) {
        flag = 1;
      }
    }
  }
  if (flag == 1) {
    printf("No");
  } else {
    printf("Yes");
  }
  return 0;
}
