#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 100;
const long long N = 1e6 + 100;
const long long POLTOS = 50;
const long long SOTKA = 100;
const long long P = 1e9 + 7;
const long double eps = 1e-7;
const long long base = 1e9;
const long long M = 1e4;
const long long MAXN = 1e6 + 100;
const long long MAXN1 = 2 * 1e2;
long long a[MAXN];
bool check(string s, string s1) {
  if (s.size() != s1.size()) return false;
  bool flag = true;
  for (long long i = 0; i < s1.size(); i++) {
    if (s[i] == 'o' || s[i] == 'O' || s[i] == '0') {
      if (s1[i] == 'o' || s1[i] == 'O' || s1[i] == '0') continue;
    }
    if (tolower(s[i]) == tolower(s1[i])) continue;
    if (s[i] == '1' || s[i] == 'L' || s[i] == 'l' || s[i] == 'I' ||
        s[i] == 'i') {
      if (s1[i] == '1' || s1[i] == 'L' || s1[i] == 'l' || s1[i] == 'I' ||
          s1[i] == 'i')
        continue;
    }
    flag = false;
  }
  return flag;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n;
  cin >> n;
  bool flag = true;
  for (long long i = 0; i < n; i++) {
    string s1;
    cin >> s1;
    if (check(s, s1)) flag = false;
  }
  cout << (flag ? "Yes" : "No");
  return 0;
}
