#include <bits/stdc++.h>
using namespace std;
const long long mod = 2000000000000000003;
const int maxn = 1e5 + 9;
const int MAXN = 1000 + 5;
using namespace std;
int in() {
  char c = getchar();
  int t = 0;
  while (c < '0' || c > '9') {
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    t = t * 10 + c - '0';
    c = getchar();
  }
  return t;
}
int n, m;
string s[maxn];
set<string> ans, res;
pair<string, string> p[maxn];
bool ch() {
  for (int i = 0; i < m; i++) {
    if (ans.find(p[i].first) != ans.end() && ans.find(p[i].second) != ans.end())
      return 0;
  }
  return 1;
}
void dfs(int i) {
  if (i == n) {
    if (ch()) {
      if (ans.size() > res.size()) {
        res = ans;
      }
    }
    return;
  }
  ans.insert(s[i]);
  dfs(i + 1);
  ans.erase(s[i]);
  dfs(i + 1);
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    ans.clear();
    res.clear();
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> p[i].first >> p[i].second;
    }
    dfs(0);
    cout << res.size() << endl;
    for (set<string>::iterator it = res.begin(); it != res.end(); it++) {
      cout << *it << endl;
    }
  }
  return 0;
}
