public void solve() throws IOException {
    int n = nextInt();
    int m = nextInt();
    
    Map<Integer, List<Count>> memory = new HashMap<Integer, List<Count>>();
    for (int x = 0; x < n; x++) {
      String input = nextLine();
      if (!memory.containsKey(input.length())) {
        memory.put(input.length(), new ArrayList<Count>());
      }
      memory.get(input.length()).add(new Count(input));
    }
    
    for (int x = 0; x < m; x++) {
      String test = nextLine();
      boolean found = false;
      if (memory.containsKey(test.length())) {
        Count base = new Count(test);
        for (Count c : memory.get(test.length())) {
          if (c.diffOne(base)) {
            found = true;
            break;
          }
        }
      }
      if (!found) {
        System.out.println("NO");
      } else {
        System.out.println("YES");
      }
    }
  }