#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXI = 300005;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  bool y = 1;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    if (s.length() != t.length()) continue;
    bool y2 = 1;
    for (int j = 0; j < t.length(); j++) {
      int s1 = s[j];
      int t1 = t[j];
      if (s1 > t1) {
        s1 = t[j];
        t1 = s[j];
      }
      if (s1 == t1 || s1 + 32 == t1 || (s1 == 48 && (t1 == 79 || t1 == 111)) ||
          ((s1 == 49 || s1 == 73 || s1 == 76 || s1 == 105) &&
           (t1 == 73 || t1 == 76 || t1 == 105 || t1 == 108) && s1 != t1))
        continue;
      y2 = 0;
    }
    if (y2) y = 0;
  }
  cout << ((y) ? "Yes" : "No") << endl;
  return 0;
}
