#include <bits/stdc++.h>
using namespace std;
set<string> getTeam(set<string> t, map<string, int> s,
                    vector<pair<string, string>> v, string e, int i) {
  if (e != "") {
    t.erase(t.find(e));
    s[" " + (e + " ")]++;
  }
  while ((v.begin() + i) != v.end() && (s[(" " + v[i].first) + " "] != 0 ||
                                        s[(" " + v[i].second) + " "] != 0))
    ++i;
  if (v.begin() + i == v.end()) return t;
  set<string> s1 = getTeam(t, s, v, v[i].first, i);
  set<string> s2 = getTeam(t, s, v, v[i].second, i);
  if (s1.size() >= s2.size()) return s1;
  return s2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string x, y;
  set<string> se;
  vector<pair<string, string>> xy;
  map<string, int> ma;
  int n, m;
  cin >> n >> m;
  while (n--) {
    cin >> x;
    se.insert(x);
    ma[(" " + x) + " "] = 0;
  }
  while (m--) {
    cin >> x >> y;
    xy.push_back(make_pair(x, y));
  }
  se = getTeam(se, ma, xy, "", 0);
  cout << se.size() << "\n";
  for (auto i = se.begin(); i != se.end(); ++i) cout << (*i) << "\n";
}
