#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
vector<pair<string, string>> v;
set<string> s1;
int max_size = -1000000007;
void rec(vector<pair<string, string>> v, int k, int val, set<string> s,
         string a[]) {
  int i;
  for (i = 0; i < v.size(); ++i) {
    if (s.find(v[i].first) != s.end() && s.find(v[i].second) != s.end()) return;
  }
  if (k == val) {
    if ((int)s.size() > max_size) {
      max_size = s.size();
      s1 = s;
    }
    return;
  }
  s.insert(a[k]);
  rec(v, k + 1, val, s, a);
  s.erase(a[k]);
  rec(v, k + 1, val, s, a);
}
void DJ() {
  int n, i, m;
  cin >> n >> m;
  string a[n];
  set<string> c;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (i = 0; i < m; ++i) {
    string a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  rec(v, 0, n, c, a);
  cout << max_size << "\n";
  for (auto c : s1) cout << c << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) DJ();
  return 0;
}
