#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n, m, t1, t2, top, cnt, tot, num, pos;
int l[4800010], r[4800010], ans[4800010], dfn[4800010], low[4800010],
    st[4800010], col[4800010];
bool vis[4800010];
struct edge {
  int to, nxt;
  edge(int a = 0, int b = 0) { to = a, nxt = b; }
} e[4800010];
int head[4800010], edge_cnt;
void add(int from, int to) {
  e[++edge_cnt] = edge(to, head[from]), head[from] = edge_cnt;
}
void tarjan(int x) {
  vis[st[++top] = x] = true, dfn[x] = low[x] = ++cnt;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (!dfn[y])
      tarjan(y), low[x] = min(low[x], low[y]);
    else if (vis[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (dfn[x] != low[x]) return;
  tot++;
  int now;
  do vis[now = st[top--]] = false, col[now] = tot;
  while (now != x);
}
bool check() {
  for (int i = 1; i <= ((m) + 2 * n + m + 2); ++i)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= n; ++i)
    if (col[(i)] == col[((i) + n)]) return false;
  for (int i = 1; i <= m; ++i)
    if (col[((i) + 2 * n + 1)] == col[((i) + 2 * n + m + 2)]) return false;
  return true;
}
int main() {
  read(t1), read(n), read(m), read(t2),
      add(((0) + 2 * n + 1), ((0) + 2 * n + m + 2));
  for (int i = 1; i <= m; ++i)
    add(((i) + 2 * n + m + 2), ((i - 1) + 2 * n + m + 2));
  for (int i = m - 1; i >= 0; --i)
    add(((i) + 2 * n + 1), ((i + 1) + 2 * n + 1));
  for (int i = 1; i <= t1; ++i) {
    int x, y;
    read(x), read(y);
    add(((x) + n), (y)), add(((y) + n), (x));
  }
  for (int i = 1; i <= n; ++i) {
    read(l[i]), read(r[i]);
    add((i), ((r[i]) + 2 * n + 1)), add((i), ((l[i] - 1) + 2 * n + m + 2));
    add(((r[i]) + 2 * n + m + 2), ((i) + n)),
        add(((l[i] - 1) + 2 * n + 1), ((i) + n));
  }
  for (int i = 1; i <= t2; ++i) {
    int x, y;
    read(x), read(y);
    add((x), ((y) + n)), add((y), ((x) + n));
  }
  if (!check()) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    if (col[(i)] < col[((i) + n)]) pos = max(pos, l[i]), ans[++num] = i;
  printf("%d %d\n", num, pos);
  for (int i = 1; i <= num; ++i) printf("%d ", ans[i]);
  return 0;
}
