#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, st;
  bool b = 0, ans = 1;
  cin >> s;
  int n;
  cin >> n;
  while (n--) {
    cin >> st;
    b = 0;
    if (st.size() != s.size()) continue;
    for (int i = 0; i < st.size(); i++) {
      if (s[i] == toupper(st[i]))
        continue;
      else if (s[i] == tolower(st[i]))
        continue;
      else if (s[i] == 'O' && st[i] == '0')
        continue;
      else if (s[i] == '0' && st[i] == 'O')
        continue;
      else if (s[i] == '0' && st[i] == 'o')
        continue;
      else if (s[i] == 'o' && st[i] == '0')
        continue;
      else if (s[i] == '1') {
        if (st[i] == 'i' || st[i] == 'l' || st[i] == 'I' || st[i] == 'L')
          continue;
        else
          b = 1;
      } else if (s[i] == 'i' || s[i] == 'I' || s[i] == 'l' || s[i] == 'L') {
        if (st[i] == '1' || st[i] == 'i' || st[i] == 'I' || st[i] == 'l' ||
            st[i] == 'L')
          continue;
        else
          b = 1;
      } else
        b = 1;
    }
    if (!b) ans = 0;
  }
  if (!ans)
    cout << "No\n";
  else
    cout << "Yes\n";
  return 0;
}
