#include <bits/stdc++.h>
using namespace std;
int n, i, j, k, t;
string s, m;
int main() {
  cin >> s >> n;
  for (i = 0; i <= s.length(); i++) {
    if (s[i] != '_' && isupper(s[i])) s[i] = tolower(s[i]);
    if (s[i] == 'o')
      s[i] = '0';
    else if (s[i] == 'l' || s[i] == 'i')
      s[i] = '1';
  }
  for (t = 1; t <= n; t++) {
    cin >> m;
    for (j = 0; j <= m.length(); j++) {
      if (m[j] != '_' && isupper(m[j])) m[j] = tolower(m[j]);
      if (m[j] == 'o')
        m[j] = '0';
      else if (m[j] == 'i' || m[j] == 'l')
        m[j] = '1';
    }
    if (m == s) k = 1;
  }
  if (k == 1)
    cout << "No";
  else
    cout << "Yes";
  cin >> n;
  return 0;
}
