#include <bits/stdc++.h>
using namespace std;
vector<string> func(vector<string> &v, vector<pair<string, string>> vg,
                    vector<string>::iterator it) {
  if (it != v.end()) v.erase(it);
  vector<string> a = v;
  vector<string> b = v;
  for (int i = 0; i < vg.size(); i++) {
    auto it = find(a.begin(), a.end(), vg[i].first);
    auto it1 = find(b.begin(), b.end(), vg[i].second);
    if ((it != a.end()) and (it1 != b.end())) {
      a = func(a, vg, it);
      b = func(b, vg, it1);
      if (a.size() >= b.size()) {
        v = a;
      } else
        v = b;
      break;
    }
  }
  sort(v.begin(), v.end());
  return v;
}
void func(vector<string> &v, vector<pair<string, string>> vg) {
  vector<string> a = v;
  vector<string> b = v;
  for (int i = 0; i < vg.size(); i++) {
    auto it = find(a.begin(), a.end(), vg[i].first);
    auto it1 = find(b.begin(), b.end(), vg[i].second);
    if ((it != a.end()) and (it1 != b.end())) {
      a = func(a, vg, it);
      b = func(b, vg, it1);
      if (a.size() >= b.size()) {
        v = a;
      } else
        v = b;
      break;
    }
  }
  sort(v.begin(), v.end());
}
int main() {
  int n, m;
  string t, a, b;
  vector<string> v;
  vector<pair<string, string>> dg;
  cin >> n;
  cin >> m;
  for (int i = 0; i < n; i++) {
    cin >> t;
    v.push_back(t);
  }
  for (int i = 0; i < m; i++) {
    cin >> a;
    cin >> b;
    pair<string, string> p(a, b);
    dg.push_back(p);
  }
  func(v, dg, v.end());
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << endl;
  }
  return 0;
}
