#include <bits/stdc++.h>
using namespace std;
string case2 = "O0o";
string case3 = "1LlIi";
inline bool find_(const string& s, const char& c) {
  return s.find(c) != string::npos;
}
bool compare(const string& s, const string& t) {
  if (s.size() != t.size()) return 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == t[i]) continue;
    if (tolower(s[i]) == tolower(t[i])) continue;
    if (find_(case2, s[i]) && find_(case2, t[i])) continue;
    if (find_(case3, s[i]) && find_(case3, t[i])) continue;
    return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  string s;
  cin >> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    if (compare(s, t)) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
