#include <bits/stdc++.h>
using namespace std;
map<char, set<char>> optionsForChars;
string logins[1000];
void createOptions() {
  string s = "_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  sort(s.begin(), s.end());
  string sets[] = {"0Oo",   "1ILil", "2",     "3",   "4",  "5",     "6",  "7",
                   "8",     "9",     "Aa",    "Bb",  "Cc", "Dd",    "Ee", "Ff",
                   "Gg",    "Hh",    "1ILil", "Jj",  "Kk", "1ILil", "Mm", "Nn",
                   "0Oo",   "Pp",    "Qq",    "Rr",  "Ss", "Tt",    "Uu", "Vv",
                   "Ww",    "Xx",    "Yy",    "Zz",  "_",  "Aa",    "Bb", "Cc",
                   "Dd",    "Ee",    "Ff",    "Gg",  "Hh", "1ILil", "Jj", "Kk",
                   "1ILil", "Mm",    "Nn",    "0Oo", "Pp", "Qq",    "Rr", "Ss",
                   "Tt",    "Uu",    "Vv",    "Ww",  "Xx", "Yy",    "Zz"};
  for (int i = 0; i < s.length(); i++) {
    set<char> chars;
    string charsString = sets[i];
    for (int j = 0; j < charsString.length(); j++) chars.insert(charsString[j]);
    optionsForChars[s[i]] = chars;
  }
}
string transform(string s) {
  string res = "";
  for (int i = 0; i < s.size(); i++)
    for (auto ch : optionsForChars[s[i]]) res += ch;
  return res;
}
int main() {
  createOptions();
  string s;
  int n;
  cin >> s;
  cin >> n;
  string transformedS = transform(s);
  for (int i = 0; i < n; i++) cin >> logins[i];
  for (int i = 0; i < n; i++) {
    if (logins[i].length() != s.length()) {
      continue;
    }
    if (transform(logins[i]) == transform(s)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
