#include <bits/stdc++.h>
using namespace std;
const int delta = 'A' - 'a';
string mainStr;
inline bool isEq(const string &input) {
  for (unsigned int i = 0; i < mainStr.length(); i++) {
    if (!(mainStr[i] == input[i] || mainStr[i] == input[i] - delta ||
          mainStr[i] == 'i' && (input[i] == '1' || input[i] == 'l' ||
                                input[i] == 'I' || input[i] == 'L') ||
          mainStr[i] == 'o' && input[i] == '0')) {
      return false;
    }
  }
  return true;
}
int main() {
  cin >> mainStr;
  for (unsigned int i = 0; i < mainStr.length(); i++) {
    if (mainStr[i] >= 'A' && mainStr[i] <= 'Z') {
      mainStr[i] = mainStr[i] - delta;
    }
    if (mainStr[i] == '1' || mainStr[i] == 'l') {
      mainStr[i] = 'i';
    } else if (mainStr[i] == '0') {
      mainStr[i] = 'o';
    }
  }
  unsigned int n;
  cin >> n;
  string tempStr;
  bool isOk = true, wordIsEq = true;
  for (unsigned int i = 0; i < n; i++) {
    cin >> tempStr;
    if (tempStr.length() != mainStr.length()) continue;
    if (isOk) {
      isOk = !isEq(tempStr);
    }
  }
  if (isOk) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
