#include <bits/stdc++.h>
int* m[111111];
int courses[111111];
int done[111111];
int ans[111111];
int n, k, STOP;
using namespace std;
set<int> mySet;
void Read() {
  int i, l, j;
  m[0] = new int[1];
  scanf("%d%d", &n, &k);
  for (i = 0; i < k; i++) scanf("%d", &courses[i]);
  for (i = 0; i < n; i++) {
    scanf("%d", &l);
    m[i + 1] = new int[l + 1];
    m[i + 1][0] = l;
    for (j = 1; j <= l; j++) scanf("%d", &m[i + 1][j]);
  }
  return;
}
void DFS(int x) {
  int i;
  for (i = 1; i <= m[x][0]; i++)
    if (!done[m[x][i]]) {
      if (m[x][i] == 0) {
        done[x] = 1;
        ans[ans[0] + 1] = x;
        ans[0]++;
        break;
      } else {
        if (mySet.count(m[x][i])) {
          STOP = 1;
          return;
        }
        mySet.insert(m[x][i]);
        DFS(m[x][i]);
      }
    }
  if ((!m[x][0]) && (!done[x])) {
    done[x] = 1;
    ans[ans[0] + 1] = x;
    ans[0]++;
  } else {
    if ((i == m[x][0] + 1) && (!done[x])) {
      done[x] = 1;
      ans[ans[0] + 1] = x;
      ans[0]++;
    }
  }
  return;
}
void Write(int m[], int l) {
  int i;
  if (!STOP) {
    printf("%d\n", l);
    for (i = 1; i <= l; i++) printf("%d ", m[i]);
  } else
    printf("-1\n");
  return;
}
int main() {
  int i;
  Read();
  for (i = 0; i < k; i++)
    if (!done[courses[i]]) {
      set<int> mySet;
      DFS(courses[i]);
    }
  Write(ans, ans[0]);
  return 0;
}
