#include <bits/stdc++.h>
using namespace std;
int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int n, i, j;
  vector<string> v;
  cin >> s >> n;
  for (i = 0; i < n; i++) {
    string t;
    cin >> t;
    if (t.length() == s.length()) v.push_back(t);
  }
  for (i = 0; i < v.size(); i++) {
    for (j = 0; j < s.length(); j++) {
      if (s[j] != v[i][j]) {
        if (s[j] == '1') {
          if (v[i][j] == 'l' || v[i][j] == 'I' || v[i][j] == 'L' ||
              v[i][j] == 'i')
            continue;
          else
            break;
        } else if (s[j] == 'l') {
          if (v[i][j] == '1' || v[i][j] == 'I' || v[i][j] == 'i' ||
              v[i][j] == 'L')
            continue;
          else
            break;
        } else if (s[j] == 'I') {
          if (v[i][j] == 'l' || v[i][j] == '1' || v[i][j] == 'i' ||
              v[i][j] == 'L')
            continue;
          else
            break;
        } else if (s[j] == 'i') {
          if (v[i][j] == 'l' || v[i][j] == '1' || v[i][j] == 'I' ||
              v[i][j] == 'L')
            continue;
          else
            break;
        } else if (s[j] == 'L') {
          if (v[i][j] == 'l' || v[i][j] == '1' || v[i][j] == 'i' ||
              v[i][j] == 'I')
            continue;
          else
            break;
        } else if (s[j] == '0' && (v[i][j] == 'O' || v[i][j] == 'o'))
          continue;
        else if ((s[j] == 'O' || s[j] == 'o') && v[i][j] == '0')
          continue;
        else if (s[j] - 32 == v[i][j] || v[i][j] - 32 == s[j])
          continue;
        else
          break;
      }
    }
    if (j == s.length()) break;
  }
  if (i == v.size())
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
