#include <bits/stdc++.h>
using namespace std;
int type(char c) {
  switch (c) {
    case '0':
    case 'O':
    case 'o':
      return 1;
      break;
    case '1':
    case 'I':
    case 'L':
    case 'i':
    case 'l':
      return 2;
      break;
  }
  return 0;
}
bool analiz(char a, char b) {
  return (type(a) != 0 && type(a) == type(b)) || a == b ||
         max(a, b) - min(a, b) == 32;
}
int main() {
  string s, t[1000];
  int n, p = 0, l;
  cin >> s >> n;
  l = s.length();
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
    if (l != t[i].length()) {
      --i;
      --n;
    }
  }
  for (int i = 0; i < n && !p; ++i)
    for (int j = 0; j < l; ++j) {
      if (!analiz(s[j], t[i][j])) break;
      if (j == l - 1) p = 1;
    }
  if (p)
    cout << "No\n";
  else
    cout << "Yes\n";
}
