#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> a, gt;
vector<bool> used;
vector<long long> topsort;
vector<long long> component;
long long curr = 0;
void dfs1(long long v) {
  used[v] = true;
  for (auto i : a[v]) {
    if (used[i]) continue;
    dfs1(i);
  }
  topsort.push_back(v);
}
void dfs2(long long v) {
  component[v] = curr;
  for (auto i : gt[v]) {
    if (component[i] != -1) continue;
    dfs2(i);
  }
}
int32_t main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios::sync_with_stdio(false);
  long long n, p, M, m;
  cin >> n >> p >> M >> m;
  a.resize(2 * (p + M));
  used.resize(2 * (p + M), false);
  for (long long i = 0; i < n; i++) {
    long long first, second;
    cin >> first >> second;
    first--;
    second--;
    a[p + first].push_back(second);
    a[p + second].push_back(first);
  }
  for (long long i = 2 * p + M - 1; i > 2 * p; i--) a[i].push_back(i - 1);
  for (long long i = 2 * p + M; i < p + p + M + M - 1; i++)
    a[i].push_back(i + 1);
  for (long long i = 0; i < p; i++) {
    long long t1, t2;
    cin >> t1 >> t2;
    a[i].push_back(p + p + t1 - 1);
    if (t2 != M) a[i].push_back(p + p + M + t2);
    if (t2 != M) a[p + p + t2].push_back(p + i);
    a[p + p + M + t1 - 1].push_back(p + i);
  }
  for (long long i = 0; i < m; i++) {
    long long first, second;
    cin >> first >> second;
    first--;
    second--;
    a[first].push_back(p + second);
    a[second].push_back(p + first);
  }
  long long tmp = a.size();
  for (long long i = 0; i < tmp; i++) {
    if (used[i]) continue;
    dfs1(i);
  }
  gt.resize(tmp, vector<long long>(0));
  for (long long i = 0; i < tmp; i++) {
    for (auto j : a[i]) {
      gt[j].push_back(i);
    }
  }
  component.resize(tmp, -1);
  reverse(topsort.begin(), topsort.end());
  for (auto i : topsort) {
    if (component[i] != -1) continue;
    dfs2(i);
    curr++;
  }
  for (long long i = 0; i < p; i++) {
    if (component[i] == component[p + i]) {
      cout << -1;
      return 0;
    }
  }
  for (long long i = 0; i < M; i++) {
    if (component[p + p + i] == component[p + p + M + i]) {
      cout << -1;
      return 0;
    }
  }
  vector<long long> ans;
  for (long long i = 0; i < p; i++) {
    if (component[i] > component[p + i]) {
      ans.push_back(i);
    }
  }
  long long ff = 0;
  for (long long i = 0; i < M; i++) {
    if (component[i + p + p] > component[i + p + p + M]) {
      ff++;
    }
  }
  cout << ans.size() << " " << ff << '\n';
  for (auto i : ans) cout << i + 1 << " ";
  return 0;
}
