#include <bits/stdc++.h>
using namespace std;
const int N = 1010, Mod = 1e9 + 7;
string s, t[N];
int f(string s, string t) {
  int x = s.size(), y = t.size();
  if (x != y)
    return 1;
  else {
    for (int i = 0; i < s.size(); i++) {
      if ((s[i] == '0' && (t[i] == 'O' || t[i] == 'o')) ||
          ((s[i] == 'O' || s[i] == 'o') && t[i] == '0'))
        continue;
      else if ((s[i] == '1' &&
                (t[i] == 'l' || t[i] == 'I' || t[i] == 'i' || t[i] == 'L')) ||
               (t[i] == '1' &&
                (s[i] == 'l' || s[i] == 'I' || s[i] == 'L' || s[i] == 'i')))
        continue;
      else if ((s[i] - 'a') == (t[i] - 'a') || (s[i] - 'A') == (t[i] - 'A'))
        continue;
      else if ((s[i] - 'a') == (t[i] - 'A') || (s[i] - 'A') == (t[i] - 'a'))
        continue;
      else if (s[i] == 'l' && t[i] == 'i')
        continue;
      else if (s[i] == 'L' && t[i] == 'i')
        continue;
      else if (s[i] == 'l' && t[i] == 'I')
        continue;
      else if (s[i] == 'L' && t[i] == 'I')
        continue;
      else if (t[i] == 'l' && s[i] == 'i')
        continue;
      else if (t[i] == 'L' && s[i] == 'i')
        continue;
      else if (t[i] == 'l' && s[i] == 'I')
        continue;
      else if (t[i] == 'L' && s[i] == 'I')
        continue;
      else
        return 1;
    }
    return 0;
  }
}
int main() {
  cin >> s;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> t[i];
  for (int i = 1; i <= n; i++)
    if (!f(s, t[i])) {
      cout << "No\n";
      return 0;
    }
  cout << "Yes\n";
  return 0;
}
