#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int inf = 1e9;
int main() {
  int n;
  string s;
  cin >> s;
  cin >> n;
  for (int j = 0; j < s.size(); j++) {
    if ('A' <= s[j] && s[j] <= 'Z') s[j] += ' ';
    if (s[j] == '0') s[j] = 'o';
    if (s[j] == '1' || s[j] == 'l') s[j] = 'i';
  }
  string t;
  for (int i = 0; i <= n; i++) {
    cin >> t;
    for (int j = 0; j < t.size(); j++) {
      if ('A' <= t[j] && t[j] <= 'Z') t[j] += ' ';
      if (t[j] == '0') t[j] = 'o';
      if (t[j] == '1' || t[j] == 'l') t[j] = 'i';
    }
    if (t == s) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
