#include <bits/stdc++.h>
using namespace std;
string a[22];
map<string, int> id;
int bad[22][22];
int main() {
  int n, k;
  while (cin >> n >> k) {
    memset(bad, 0, sizeof bad);
    id.clear();
    for (int i = 0, _a = (n); i < _a; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = 0, _a = (n); i < _a; i++) id[a[i]] = i;
    for (int i = 0, _a = (k); i < _a; i++) {
      string x, y;
      cin >> x >> y;
      bad[id[x]][id[y]] = 1;
    }
    int best = 0, save = 0;
    for (int mask = 0, _a = ((1 << (n))); mask < _a; mask++)
      if (__builtin_popcount(mask) > best) {
        int sum = 0;
        for (int i = 0, _a = (n); i < _a; i++)
          if ((mask & (1 << (i))))
            for (int j = 0, _a = (n); j < _a; j++)
              if ((mask & (1 << (j)))) sum += bad[i][j];
        if (sum == 0) {
          best = __builtin_popcount(mask);
          save = mask;
        }
      }
    cout << best << endl;
    for (int i = 0, _a = (n); i < _a; i++)
      if ((save & (1 << (i)))) cout << a[i] << endl;
  }
  return 0;
}
