#include <bits/stdc++.h>
using namespace std;
vector<vector<string>> result;
void findSubsets(vector<string>& x, int index, vector<string>& combination) {
  if (index == x.size()) {
    result.push_back(combination);
    return;
  }
  combination.push_back(x[index]);
  findSubsets(x, index + 1, combination);
  combination.pop_back();
  findSubsets(x, index + 1, combination);
}
bool compare(vector<string> v1, vector<string> v2) {
  return v1.size() > v2.size();
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> x, c;
  pair<string, string> arr[m];
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    x.push_back(str);
  }
  for (int i = 0; i < m; i++) {
    cin >> arr[i].first >> arr[i].second;
  }
  findSubsets(x, 0, c);
  sort(result.begin(), result.end(), compare);
  vector<string> ans;
  for (int i = 0; i < result.size(); i++) {
    bool flag = true;
    sort(result[i].begin(), result[i].end());
    for (int j = 0; j < m; j++) {
      std::vector<string>::iterator it1, it2;
      it1 = std::find(result[i].begin(), result[i].end(), arr[j].first);
      it2 = std::find(result[i].begin(), result[i].end(), arr[j].second);
      if (it1 != result[i].end() && it2 != result[i].end()) {
        flag = false;
      }
    }
    if (flag) {
      ans = result[i];
      break;
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
