#include <bits/stdc++.h>
using namespace std;
const int N = 400400;
vector<int> graf[N * 4], graf_t[N * 4], graf_sss_t[N * 4], res;
int vis[N * 4], sss[N * 4], an[N * 4], check[N * 4];
bool topo[N * 4];
stack<int> s, d;
queue<int> q;
void dfs(int v, int x) {
  d.push(v);
  while (!d.empty()) {
    v = d.top(), d.pop();
    vis[v] = min(2, x + 1), sss[v] = x;
    if (x == 0) {
      for (auto u : graf[v])
        if (!vis[u]) d.push(u);
      s.push(v);
    } else
      for (auto u : graf_t[v])
        if (vis[u] != 2) d.push(u);
  }
}
void toposort() {
  int v;
  while (!q.empty()) {
    v = q.front(), q.pop();
    if (!topo[v]) {
      topo[an[v]] = true;
      for (auto u : graf_sss_t[v]) {
        check[u]--;
        if (check[u] == 0) q.push(u);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, p, f, m, a, b, ctr = 0;
  cin >> n >> p >> f >> m;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    graf[a + p + f].push_back(b), graf[b + p + f].push_back(a),
        graf_t[a].push_back(b + p + f), graf_t[b].push_back(a + p + f);
  }
  for (int i = 1; i <= p; i++) {
    cin >> a >> b;
    if (a > 1)
      graf[i].push_back(a + p), graf[a + 2 * p + f].push_back(i + p + f),
          graf_t[a + p].push_back(i),
          graf_t[i + p + f].push_back(a + 2 * p + f);
    if (b < f)
      graf[i].push_back(b + 2 * p + f + 1),
          graf[b + p + 1].push_back(i + p + f),
          graf_t[b + 2 * p + f + 1].push_back(i),
          graf_t[i + p + f].push_back(b + p + 1);
  }
  for (int i = 1; i < f; i++)
    graf[i + p + 1].push_back(i + p),
        graf[i + 2 * p + f].push_back(i + 2 * p + f + 1),
        graf_t[i + p].push_back(i + p + 1),
        graf_t[i + 2 * p + f + 1].push_back(i + 2 * p + f);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    graf[a].push_back(b + p + f), graf[b].push_back(a + p + f),
        graf_t[a + p + f].push_back(b), graf_t[b + p + f].push_back(a);
  }
  for (int i = 1; i <= 2 * (p + f); i++)
    if (!vis[i]) dfs(i, 0);
  while (!s.empty()) {
    a = s.top(), s.pop();
    if (vis[a] != 2) dfs(a, ++ctr);
  }
  for (int i = 1; i <= 2 * (p + f); i++) {
    for (auto u : graf[i])
      if (sss[i] != sss[u])
        graf_sss_t[sss[u]].push_back(sss[i]), check[sss[i]]++;
    if (i <= p + f) {
      if (sss[i] == sss[i + p + f]) {
        cout << -1;
        return 0;
      }
      an[sss[i]] = sss[i + p + f], an[sss[i + p + f]] = sss[i];
    }
  }
  for (int i = 1; i <= ctr; i++)
    if (!check[i]) q.push(i);
  toposort();
  for (int i = 1; i <= p; i++)
    if (!topo[sss[i]]) res.push_back(i);
  for (int i = p + 2; i <= p + f; i++)
    if (topo[sss[i]]) {
      cout << res.size() << " " << i - p - 1 << '\n';
      break;
    }
  for (auto u : res) cout << u << " ";
}
