#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5;
vector<int> adj[N + 5];
vector<int> vist(N + 5, 0);
vector<int> ans;
bool dfs(int x) {
  vist[x] = 1;
  for (auto i : adj[x]) {
    if (vist[i] == 0) {
      if (dfs(i) == false) return false;
    } else if (vist[i] == 1) {
      return false;
    }
  }
  vist[x] = 2;
  ans.push_back(x);
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int k;
  cin >> n >> k;
  int arr[k];
  for (int i = (int)(0); i <= (int)(k - 1); i++) {
    cin >> arr[i];
  }
  for (int i = (int)(1); i <= (int)(n); i++) {
    int t;
    cin >> t;
    for (int j = (int)(1); j <= (int)(t); j++) {
      int x;
      cin >> x;
      adj[i].push_back(x);
    }
  }
  for (int i = (int)(0); i <= (int)(k - 1); i++) {
    if (vist[arr[i]] == 0) {
      if (dfs(arr[i]) == false) {
        cout << "-1"
             << "\n";
        return 0;
      }
    }
  }
  cout << ans.size() << "\n";
  for (int i = (int)(0); i <= (int)(ans.size() - 1); i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}
