#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
map<int, string> MM;
vector<int> adj[20];
int n, m;
bool val(vector<int> &v) {
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v.size(); j++) {
      if (i == j) continue;
      for (int k = 0; k < adj[v[i]].size(); k++) {
        if (v[j] == adj[v[i]][k]) return 0;
      }
    }
  }
  return 1;
}
void solve() {
  int maxi = 0;
  vector<int> v, sol;
  for (int i = 0; i < (1 << n); i++) {
    v.clear();
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) v.push_back(j);
    }
    if (val(v)) {
      if (v.size() > maxi) {
        maxi = v.size();
        sol = v;
      }
    }
  }
  cout << maxi << endl;
  vector<string> name;
  for (int i = 0; i < sol.size(); i++) name.push_back(MM[sol[i]]);
  sort(name.begin(), name.end());
  for (int i = 0; i < name.size(); i++) cout << name[i] << endl;
}
int main() {
  cin >> n >> m;
  string s, s1;
  for (int i = 0; i < n; i++) {
    cin >> s;
    M[s] = i;
    MM[i] = s;
  }
  for (int i = 0; i < m; i++) {
    cin >> s >> s1;
    adj[M[s]].push_back(M[s1]);
  }
  solve();
}
