#include <bits/stdc++.h>
using namespace std;
char f(char c) {
  if (c <= 'Z' && c >= 'A') c = 'a' + c - 'A';
  if (c == '0') c = 'o';
  if (c == '1') c = 'l';
  if (c == 'i') c = 'l';
  return c;
}
int main() {
  string kek;
  cin >> kek;
  int n;
  cin >> n;
  vector<string> mem(n);
  for (auto &x : mem) cin >> x;
  for (auto &x : mem)
    for (char &c : x) c = f(c);
  for (char &c : kek) c = f(c);
  string ans = "Yes";
  for (auto x : mem)
    if (x == kek) ans = "No";
  cout << ans;
}
