#include <bits/stdc++.h>
using namespace std;
int n, m, mr;
vector<string> v;
string s, s2, tmp, res;
vector<pair<int, int> > e;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < m; i++) {
    cin >> s >> s2;
    int a;
    for (a = 0; a < n; a++)
      if (v[a] == s) break;
    int b;
    for (b = 0; b < n; b++)
      if (v[b] == s2) break;
    e.push_back(make_pair(a, b));
  }
  int mx = (int)pow(2.0, n);
  for (int x = mx - 1; x > 0; x--) {
    bool f = true;
    for (int i = 0; i < e.size(); i++) {
      int e1 = n - e[i].first - 1, e2 = n - e[i].second - 1;
      if ((x >> e1 & 1) && (x >> e2 & 1)) f = false;
    }
    if (f) {
      int amx = mx;
      int r = 0;
      for (int o = 0; o < n; o++) {
        if (x & (mx >> 1)) r++;
        mx /= 2;
      }
      mx = amx;
      tmp = "";
      for (int o = 0; o < n; o++) {
        if (x & (mx >> 1)) tmp += v[o] + "\n";
        mx /= 2;
      }
      mx = amx;
      if (r > mr) res = tmp, mr = r;
    }
  }
  cout << mr << endl;
  cout << res;
  return 0;
}
