#include <bits/stdc++.h>
using namespace std;
string arr[20];
vector<string> out;
vector<pair<string, string> > vp(200);
int n, m;
void rec(int idx, vector<string> vec) {
  if (idx == n) return;
  bool can;
  for (int i = idx; i < n; i++) {
    can = true;
    for (int j = 0; j < int((vec).size()) && can; j++)
      for (int k = 0; k < m; k++)
        if (arr[i] == vp[k].first && vec[j] == vp[k].second ||
            arr[i] == vp[k].second && vec[j] == vp[k].first) {
          can = false;
          break;
        }
    if (can) {
      vec.push_back(arr[i]);
      if (int((vec).size()) > int((out).size())) out = vec;
      rec(i + 1, vec);
      vec.pop_back();
    }
  }
}
int main() {
  vector<string> v;
  string x, y;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < m; i++) cin >> vp[i].first >> vp[i].second;
  rec(0, v);
  cout << int((out).size()) << endl;
  for (int i = 0; i < int((out).size()); i++) cout << out[i] << endl;
  return 0;
}
