#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int A, sn, sp, B, n, ans[N], u, f;
vector<int> S[N];
void E(int x, int y) { S[x].push_back(y); }
int num[N], low[N], scc[N], st[N], cnt, top, inc;
bool in[N];
inline void DFS(int x) {
  num[x] = low[x] = ++cnt;
  st[++top] = x;
  in[x] = 1;
  for (int i = 0; i < S[x].size(); i++) {
    int y = S[x][i];
    if (!num[y])
      DFS(y), low[x] = min(low[x], low[y]);
    else if (in[y])
      low[x] = min(low[x], num[y]);
  }
  if (num[x] == low[x]) {
    scc[x] = ++inc;
    while (st[top] != x) scc[st[top]] = inc, in[st[top]] = 0, top--;
    top--;
    in[x] = 0;
  }
}
inline void _SAT() {
  int x, y, tot = n * 2;
  for (int i = 1; i <= tot; i++)
    if (!num[i]) DFS(i);
  for (int i = 1; i <= sn; i++) {
    x = scc[i];
    y = scc[((i) + n)];
    if (x == y) {
      puts("-1");
      return;
    }
    if (x < y) ans[++u] = i;
  }
  for (int i = 1; i <= sp; i++) {
    x = scc[(sn + (i))];
    y = scc[(((sn + (i))) + n)];
    if (x == y) {
      puts("-1");
      return;
    }
    if (x < y) f = i;
  }
  printf("%d %d\n", u, f);
  for (int i = 1; i <= u; i++) printf("%d ", ans[i]);
}
int main() {
  scanf("%d%d%d%d", &A, &sn, &sp, &B);
  n = sn + sp;
  int x, y, l, r;
  for (int i = 1; i <= A; i++) {
    scanf("%d%d", &x, &y);
    E(((x) + n), y), E(((y) + n), x);
  }
  for (x = 1; x <= sn; x++) {
    scanf("%d%d", &l, &r);
    r++;
    E(x, (sn + (l))), E((((sn + (l))) + n), ((x) + n));
    if (r <= sp) E(x, (((sn + (r))) + n)), E((sn + (r)), ((x) + n));
  }
  for (int i = 1; i <= B; i++) {
    scanf("%d%d", &x, &y);
    E(x, ((y) + n));
    E(y, ((x) + n));
  }
  for (int i = 1; i < sp; i++) {
    l = (sn + (i));
    r = (sn + (i + 1));
    E(r, l);
    E(((l) + n), ((r) + n));
  }
  _SAT();
  return 0;
}
