#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238;
const double E = 2.718281828459045235;
const int MOD = 1000000007;
const long long INF = 1000000000;
string pre(string a) {
  for (int i = 0; i < ((int)(a).size()); i++) {
    a[i] = tolower(a[i]);
    if (a[i] == 'o') a[i] = '0';
    if (a[i] == 'i' || a[i] == 'l') a[i] = '1';
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  string s, a;
  cin >> s >> n;
  s = pre(s);
  for (int i = 0; i < n; i++) {
    cin >> a;
    a = pre(a);
    if (s == a) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
