#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string t, ss = "0123456789", s, sp1 = "0Oo", sp2 = "1IiLl";
  cin >> t;
  int n;
  for (int i = 0; i < t.size(); ++i)
    if (t[i] == '0')
      t[i] = 'o';
    else if (t[i] == 'l')
      t[i] = '1';
    else if (t[i] == 'I')
      t[i] = '1';
    else if (t[i] != 'L' && t[i] != '_' && ss.find(t[i]) > ss.size() &&
             int(t[i]) < 97)
      t[i] = char(int(t[i]) + 32);
  cin >> n;
  for (int lol = 0; lol < n; ++lol) {
    string s;
    cin >> s;
    if (s.size() != t.size()) continue;
    for (int i = 0; i < s.size(); ++i)
      if (s[i] != '_' && ss.find(s[i]) > ss.size() && int(s[i]) < 97)
        s[i] = char(int(s[i]) + 32);
    int f = 0;
    for (int i = 0; i < t.size() && f == 0; ++i)
      if (sp1.find(s[i]) < sp1.size() && sp1.find(t[i]) < sp1.size())
        continue;
      else if (sp2.find(s[i]) < sp2.size() && sp2.find(t[i]) < sp2.size())
        continue;
      else if (t[i] != s[i])
        f = 1;
    if (f == 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
