#include <bits/stdc++.h>
using namespace std;
string transform(string s) {
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') s[i] = char(s[i] - 'A' + 'a');
    if (s[i] == 'o') s[i] = '0';
    if (s[i] == 'l' || s[i] == 'i') s[i] = '1';
  }
  return s;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  string s;
  int n;
  cin >> s >> n;
  s = transform(s);
  for (int i = 0; i < n; i++) {
    string w;
    cin >> w;
    w = transform(w);
    if (s == w) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
