#include <bits/stdc++.h>
using namespace std;
int dfs_number;
int finish_number;
int num[100050];
int finish[100050];
int arr[100050];
vector<int> adj[100050];
bool vis[100050];
int n, m;
bool cycle = false;
int cnt = 0;
queue<int> res[100050];
int status[100050];
void dfs(int u, int v) {
  if (cycle) return;
  cnt++;
  status[u] = 1;
  vis[u] = true;
  num[u] = dfs_number++;
  for (int i = 0; i < adj[u].size(); i++) {
    if (!vis[adj[u][i]]) {
      dfs(adj[u][i], v);
    }
    if (vis[adj[u][i]] && num[adj[u][i]] < num[u] && status[adj[u][i]] == 1) {
      cycle = true;
      return;
    }
  }
  status[u] = 2;
  finish[u] = finish_number++;
  res[v].push(u);
}
bool vis2[100050];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    while (x--) {
      int y;
      cin >> y;
      adj[i].push_back(y);
    }
  }
  for (int i = 0; i < m; i++) {
    dfs_number = 0;
    finish_number = 0;
    dfs(arr[i], arr[i]);
  }
  if (cycle) {
    cout << "-1";
    return 0;
  }
  vector<int> fres;
  for (int i = 0; i < m; i++) {
    while (!res[arr[i]].empty()) {
      if (!vis2[res[arr[i]].front()]) fres.push_back(res[arr[i]].front());
      vis2[res[arr[i]].front()] = true;
      res[arr[i]].pop();
    }
  }
  cout << fres.size() << endl;
  for (int i = 0; i < fres.size(); i++) cout << fres[i] << " ";
  return 0;
}
