#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
vector<int> e[N], e1[N];
int used[N], n, m, h, t;
void check(int v, int u) {
  int k1, k2, k3 = k1 = k2 = 0;
  static int timer = 10;
  timer++;
  for (int to : e[v]) {
    if (to == u) {
      continue;
    }
    used[to] = timer;
    k1++;
  }
  for (int to : e[u]) {
    if (to == v) {
      continue;
    }
    k3 += used[to] == timer;
    used[to] = -timer;
    k2++;
  }
  k1 -= k3;
  k2 -= k3;
  if (k1 < h) {
    int take = min(h - k1, k3);
    k3 -= take;
    k1 += take;
  }
  k2 += k3;
  if (k1 < h || k2 < t) {
    return;
  }
  vector<char> flag(n);
  vector<int> a, b, c;
  for (int to : e[v]) {
    if (to != u && used[to] != -timer) {
      a.push_back(to);
    }
    used[to] = timer;
  }
  for (int to : e[u]) {
    if (to == v) {
      continue;
    }
    if (used[to] == timer) {
      c.push_back(to);
    } else {
      b.push_back(to);
    }
  }
  printf("YES\n%d %d\n", v + 1, u + 1);
  while (h--)
    if (!a.empty()) {
      printf("%d ", a.back() + 1);
      a.pop_back();
    } else {
      printf("%d ", c.back() + 1);
      c.pop_back();
    }
  printf("\n");
  while (t--)
    if (!b.empty()) {
      printf("%d ", b.back() + 1);
      b.pop_back();
    } else {
      printf("%d ", c.back() + 1);
      c.pop_back();
    }
  exit(0);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    e1[x].push_back(y);
    e1[y].push_back(x);
    if (e[x].size() < h + t + 2) {
      e[x].push_back(y);
    }
    if (e[y].size() < h + t + 2) {
      e[y].push_back(x);
    }
  }
  for (int v = 0; v < n; v++)
    for (int to : e1[v]) {
      check(v, to);
    }
  printf("NO");
  return 0;
}
