#include <bits/stdc++.h>
using namespace std;
int comparer(char *s, char *ch) {
  int k = 0;
  if (strlen(s) != strlen(ch)) return 1;
  for (int i = 0; i < strlen(s); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) s[i] = s[i] + 32;
    if ((ch[i] >= 'A') && (ch[i] <= 'Z')) ch[i] = ch[i] + 32;
    if ((s[i] == '1') || (s[i] == 'l')) s[i] = 'i';
    if (s[i] == '0') s[i] = 'o';
    if ((ch[i] == '1') || (ch[i] == 'l')) ch[i] = 'i';
    if (ch[i] == '0') ch[i] = 'o';
    if (ch[i] != s[i]) k = 1;
  }
  if (k == 1)
    return 1;
  else
    return 0;
}
int main() {
  int n, c = 1;
  char s[51] = "", ch[51] = "";
  cin >> s >> n;
  for (int i = 0; i < n; i++) {
    cin >> ch;
    c = c * comparer(s, ch);
  }
  if (c == 1)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
