#include <bits/stdc++.h>
using namespace std;
void fastscan(int &number) {
  bool negative = false;
  register int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
bool comparable(pair<string, int> p1, pair<string, int> p2) {
  return p1.second < p2.second;
}
int main() {
  int n, mm;
  cin >> n >> mm;
  string m[n];
  pair<string, string> h[mm];
  string s, s2;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }
  for (int i = 0; i < mm; i++) {
    cin >> s >> s2;
    h[i].first = s;
    h[i].second = s2;
  }
  vector<string> best(0);
  for (int i = 1; i < (1 << n); i++) {
    vector<string> team;
    for (int j = 0; j < n; j++)
      if ((i >> j) & 1) team.push_back(m[j]);
    bool cont = true;
    for (int j = 0; j < mm && cont; j++)
      if (find(team.begin(), team.end(), h[j].first) != team.end() &&
          find(team.begin(), team.end(), h[j].second) != team.end())
        cont = false;
    if (cont && best.size() < team.size()) best = team;
  }
  sort(best.begin(), best.end());
  cout << best.size() << endl;
  for (int i = 0; i < best.size(); i++) cout << best[i] << '\n';
}
