#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long t, i = 0, j, n = s.length();
  cin >> t;
  for (j = 0; j < n; j++) {
    if (s[j] >= 'a' && s[j] <= 'z') s[j] = (char)(s[j] - 32);
    if (s[j] == 'I' || s[j] == 'L') s[j] = '1';
    if (s[j] == 'O') s[j] = '0';
  }
  while (t--) {
    string st;
    cin >> st;
    if (st.length() == n) {
      for (j = 0; j < n; j++) {
        if (st[j] >= 'a' && st[j] <= 'z') st[j] = (char)((int)st[j] - 32);
        if (st[j] == 'I' || st[j] == 'L') st[j] = '1';
        if (st[j] == 'O') st[j] = '0';
      }
      if (st == s) {
        i = 1;
      }
    }
  }
  if (i == 1) {
    cout << "No";
  } else
    cout << "Yes";
}
