#include <bits/stdc++.h>
using namespace std;
long long int INF = 1000000007;
long long int exp(long long int x, long long int n) {
  if (n == 0) return 1;
  if (n == 1) return x % INF;
  if (n % 2 == 0)
    return exp((x * x) % INF, n / 2);
  else
    return (x * exp((x * x) % INF, n / 2)) % INF;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j;
  long long int n, m;
  cin >> n >> m;
  vector<string> gh;
  for (i = 0; i < n; i++) {
    string k;
    cin >> k;
    gh.push_back(k);
  }
  pair<string, string> no[m];
  for (i = 0; i < m; i++) {
    string k, tp;
    cin >> k >> tp;
    no[i].first = k;
    no[i].second = tp;
  }
  long long int g = pow(2, n);
  vector<string> temp;
  vector<string> ans;
  long long int k1 = 0, k2 = 0, flag = 0, cur = 0;
  for (i = g - 1; i >= 1; i--) {
    temp.clear();
    for (j = 0; j < n; j++) {
      if (i & (1 << j)) {
        temp.push_back(gh[j]);
      }
    }
    flag = 0;
    for (long long int b = 0; b < m; b++) {
      k1 = 0;
      k2 = 0;
      for (long long int a = 0; a < temp.size(); a++) {
        if (temp[a] == no[b].first) k1 = 1;
        if (temp[a] == no[b].second) k2 = 1;
      }
      if (k1 == 1 && k2 == 1) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      if (temp.size() > cur) {
        cur = temp.size();
        ans.clear();
        ans = temp;
      }
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
