#include <bits/stdc++.h>
using namespace std;
int m1, m2, n, m, cnt, tot, top, T;
int head[2000005], Next[2000005], vet[2000005];
int col[2000005], st[2000005], dfn[2000005], low[2000005], vis[2000005];
void add(int x, int y) {
  cnt++;
  Next[cnt] = head[x];
  head[x] = cnt;
  vet[cnt] = y;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++T;
  st[++top] = x;
  vis[x] = 1;
  for (int i = head[x]; i; i = Next[i]) {
    int v = vet[i];
    if (!dfn[v]) {
      tarjan(v);
      low[x] = min(low[x], low[v]);
    } else if (vis[v])
      low[x] = min(low[x], dfn[v]);
  }
  if (low[x] == dfn[x]) {
    tot++;
    int t = -1;
    while (t != x) {
      t = st[top--];
      col[t] = tot;
      vis[t] = 0;
    }
  }
}
int main() {
  cin >> m1 >> n >> m >> m2;
  int x, y;
  for (int i = 1; i <= m1; ++i) {
    scanf("%d%d", &x, &y);
    add(((x) << 1), (((y) << 1) - 1)), add(((y) << 1), (((x) << 1) - 1));
  }
  for (int i = 0; i < m; ++i) {
    add((((n + 1 + i) << 1) - 1), (((n + 1 + i + 1) << 1) - 1));
    add(((n + 1 + i + 1) << 1), ((n + 1 + i) << 1));
  }
  add((((n + 1) << 1) - 1), ((n + 1) << 1));
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    add((((i) << 1) - 1), ((n + 1 + x - 1) << 1)),
        add((((n + 1 + x - 1) << 1) - 1), ((i) << 1));
    add((((i) << 1) - 1), (((n + 1 + y) << 1) - 1)),
        add(((n + 1 + y) << 1), ((i) << 1));
  }
  for (int i = 1; i <= m2; ++i) {
    scanf("%d%d", &x, &y);
    add((((x) << 1) - 1), ((y) << 1)), add((((y) << 1) - 1), ((x) << 1));
  }
  for (int i = 1; i <= (n + m + 1) * 2; ++i) {
    if (!dfn[i]) tarjan(i);
  }
  int ans = 0;
  for (int i = 1; i <= n + m + 1; ++i) {
    if (col[(((i) << 1) - 1)] == col[((i) << 1)]) {
      cout << i << endl;
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (col[(((i) << 1) - 1)] < col[((i) << 1)]) ans++;
  }
  cout << ans << " ";
  for (int i = 1; i <= m; ++i) {
    if (col[(((n + 1 + i) << 1) - 1)] < col[((n + 1 + i) << 1)]) {
      cout << i << endl;
      break;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (col[(((i) << 1) - 1)] < col[((i) << 1)]) printf("%d ", i);
  }
  return 0;
}
