#include <bits/stdc++.h>
using namespace std;
int main() {
  string login;
  int n, si, sc = 0;
  cin >> login >> n;
  for (int i = 0; i < n; i++) {
    sc = 0;
    string login1;
    cin >> login1;
    for (int i = 0; i < (login.size()); i++) {
      if (login[i] == login1[i]) sc++;
      if (login[i] == login1[i] - 32) sc++;
      if (login[i] == login1[i] + 32) sc++;
      if (login[i] == '0' && login1[i] == 'O' ||
          login[i] == 'O' && login1[i] == '0')
        sc++;
      if (login[i] == '0' && login1[i] == 'o' ||
          login[i] == 'o' && login1[i] == '0')
        sc++;
      if (login[i] == '1' && login1[i] == 'l' ||
          login[i] == '1' && login1[i] == 'L' ||
          login[i] == '1' && login1[i] == 'I' ||
          login[i] == '1' && login1[i] == 'i')
        sc++;
      if (login[i] == 'L' && login1[i] == '1' ||
          login[i] == 'L' && login1[i] == 'I' ||
          login[i] == 'L' && login1[i] == 'i')
        sc++;
      if (login[i] == 'I' && login1[i] == '1' ||
          login[i] == 'I' && login1[i] == 'L' ||
          login[i] == 'I' && login1[i] == 'l')
        sc++;
      if (login[i] == 'i' && login1[i] == '1' ||
          login[i] == 'i' && login1[i] == 'L' ||
          login[i] == 'i' && login1[i] == 'l')
        sc++;
      if (login[i] == 'l' && login1[i] == '1' ||
          login[i] == 'l' && login1[i] == 'I' ||
          login[i] == 'l' && login1[i] == 'i')
        sc++;
    }
    if (sc == login.size() && login.size() == login1.size()) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
