#include <bits/stdc++.h>
long long INF = 1e9 + 7;
long double eps = 1e-9;
using namespace std;
bool comp(int a, int b) { return a > b; }
class compare {
 public:
  template <class T>
  bool operator()(T a, T b) {
    return comp(a, b);
  }
};
vector<bool> vis;
vector<vector<int> > graph, ngraph;
vector<int> ans, color;
vector<int> start;
vector<int> topsort;
bool flag = 1;
void dfs0(int v) {
  if (vis[v]) return;
  vis[v] = 1;
  for (int i = 0; i < ngraph[v].size(); i++) {
    if (vis[ngraph[v][i]] && ngraph[v][i] != v) flag = 0;
    dfs0(ngraph[v][i]);
  }
  topsort.push_back(v);
}
void dfs(int v, int p) {
  if (vis[v]) return;
  if (p != -1 && color[v] != color[p] && color[v] != v) {
    printf("-1");
    exit(0);
  }
  vis[v] = 1;
  for (int i = 0; i < graph[v].size(); i++) {
    dfs(graph[v][i], v);
  }
}
map<pair<long long, long long>, bool> kek;
int main() {
  long long n, m, a, b;
  cin >> n >> m;
  graph.resize(n);
  ngraph.resize(n);
  vis.resize(n, 1);
  color.resize(n);
  vector<int> svis(n, 1);
  for (int i = 0; i < m; i++) {
    scanf("%I64d %I64d", &a, &b);
    graph[a - 1].push_back(b - 1);
    svis[b - 1] = 0;
    vis[b - 1] = 0;
  }
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a);
    color[i] = a - 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      if (kek[make_pair(color[i], color[graph[i][j]])] != 1) {
        ngraph[color[i]].push_back(color[graph[i][j]]);
        kek[make_pair(color[i], color[graph[i][j]])] = 1;
      }
    }
  }
  vector<int> sstart;
  for (int i = 0; i < n; i++) {
    if (svis[i]) sstart.push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) start.push_back(color[i]);
  }
  fill(vis.begin(), vis.end(), 0);
  for (int i = 0; i < start.size(); i++) {
    dfs(sstart[i], -1);
  }
  fill(vis.begin(), vis.end(), 0);
  for (int i = 0; i < start.size(); i++) {
    dfs0(start[i]);
  }
  fill(vis.begin(), vis.end(), 0);
  vector<long long> res;
  for (int i = 0; i < topsort.size(); i++) {
    if (!vis[topsort[i]]) {
      res.push_back(topsort[i] + 1);
      vis[topsort[i]] = 1;
    }
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) printf("%I64d\n", res[i]);
}
