#include <bits/stdc++.h>
using namespace std;
int main() {
  string login;
  int n;
  cin >> login >> n;
  string line;
  bool k1 = false, k2 = false;
  for (int i = 0; i < login.size(); i++)
    if (login[i] >= 65 && login[i] <= 90) login[i] += 32;
  for (int i = 0; i < n; i++) {
    cin >> line;
    if (!k1) {
      k2 = false;
      if (login.size() == line.size()) {
        for (int j = 0; j < line.size(); j++)
          if (line[j] >= 65 && line[j] <= 90) line[j] += 32;
        for (int j = 0; j < line.size(); j++) {
          if (login[j] == line[j])
            k2 = true;
          else {
            if ((login[j] == '0' || login[j] == 'o') &&
                (line[j] == '0' || line[j] == 'o'))
              k2 = true;
            else {
              if ((login[j] == '1' || login[j] == 'i' || login[j] == 'l') &&
                  (line[j] == '1' || line[j] == 'i' || line[j] == 'l'))
                k2 = true;
              else {
                k2 = false;
              }
            }
          }
          if (k2 == false) break;
        }
      }
      if (k2) k1 = true;
    }
  }
  if (k1)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
