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