#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::map<std::string, int> names;
  int n;
  int m;
  std::cin >> n >> m;
  int h = n;
  unsigned i = 1 << n;
  while (n--) {
    std::string name;
    std::cin >> name;
    names.emplace(std::move(name), n);
  }
  std::vector<unsigned> forbidden(m);
  for (auto&& mask : forbidden) {
    std::string a;
    std::string b;
    std::cin >> a >> b;
    mask = 1 << names.find(a)->second | 1 << names.find(b)->second;
  }
  int best_h = 0;
  unsigned best_mask = 0;
  while (i--) {
    if (h > best_h) {
      auto it =
          std::find_if(forbidden.begin(), forbidden.end(), [&](unsigned f) {
            f &= i;
            return f & (f - 1);
          });
      if (it == forbidden.end()) {
        best_h = h;
        best_mask = i;
      }
    }
    unsigned j = i & ~(i - 1);
    while (j >>= 1) {
      h++;
    }
    h--;
  }
  std::cout << best_h << '\n';
  for (const auto& p : names) {
    if (best_mask & 1 << p.second) std::cout << p.first << '\n';
  }
  return 0;
}
