#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string a[n + 1];
  int mx = 0;
  vector<pair<string, string> > b;
  vector<string> ans;
  for (int k = 1; k <= n; k++) cin >> a[k];
  for (int k = 1; k <= m; k++) {
    string s;
    cin >> s;
    string ss;
    cin >> ss;
    b.push_back({s, ss});
  }
  for (int k = 1; k < (1 << n); k++) {
    int r = 0;
    vector<string> v;
    for (int j = 0; j < n; j++) {
      if ((1 << j) & k) {
        v.push_back(a[j + 1]);
      }
    }
    for (int i = 0; i < v.size(); i++) {
      for (int ii = i + 1; ii < v.size(); ii++) {
        for (int iii = 0; iii < b.size(); iii++) {
          if ((b[iii].first == v[i] && b[iii].second == v[ii]) ||
              (b[iii].first == v[ii] && b[iii].second == v[i])) {
            r = 1;
            break;
          }
        }
        if (r == 1) {
          break;
        }
      }
      if (r == 1) {
        break;
      }
    }
    if (r == 0 && mx < v.size()) {
      mx = v.size();
      ans = v;
    }
  }
  cout << mx << endl;
  sort(ans.begin(), ans.end());
  for (int k = 0; k < ans.size(); k++) {
    cout << ans[k] << endl;
  }
  return 0;
}
