#include <bits/stdc++.h>
using namespace std;
const int mxn = 200010;
int n, m, du[mxn], h, t;
int hd[mxn], nx[mxn], to[mxn], e = 0;
bool v1[mxn], v2[mxn];
int s1[mxn], s2[mxn], s3[mxn], p1, p2, p3;
void ad(int x, int y) {
  to[++e] = y;
  nx[e] = hd[x];
  hd[x] = e;
}
void find1(int x, int y, int fl) {
  printf("%d %d\n", x, y);
  memset(v1, 0, sizeof(v1));
  if (fl) {
    int nw = 0;
    for (int i = hd[x]; i; i = nx[i]) {
      int v = to[i];
      if (v == y) continue;
      v1[v] = 1;
      printf("%d ", v);
      if (++nw == h) break;
    }
    printf("\n");
    nw = 0;
    for (int i = hd[y]; i; i = nx[i]) {
      int v = to[i];
      if (v == x || v1[v]) continue;
      printf("%d ", v);
      if (++nw >= t) break;
    }
    printf("\n");
  } else {
    int nw = 0;
    p1 = 0;
    for (int i = hd[y]; i; i = nx[i]) {
      int v = to[i];
      if (v == x) continue;
      v1[v] = 1;
      s1[++p1] = v;
      if (++nw == t) break;
    }
    nw = 0;
    for (int i = hd[x]; i; i = nx[i]) {
      int v = to[i];
      if (v == y || v1[v]) continue;
      printf("%d ", v);
      if (++nw >= h) break;
    }
    printf("\n");
    for (int i = 1; i <= p1; i++) printf("%d ", s1[i]);
    printf("\n");
  }
}
bool find2(int x, int y) {
  for (int i = hd[y]; i; i = nx[i]) {
    int v = to[i];
    v2[v] = 1;
  }
  p1 = p2 = p3 = 0;
  for (int i = hd[x]; i; i = nx[i]) {
    int v = to[i];
    if (v == y) continue;
    if (v2[v])
      s3[++p3] = v;
    else
      s1[++p1] = v;
  }
  for (int i = hd[y]; i; i = nx[i]) {
    int v = to[i];
    if (v1[v] || v == x) continue;
    s2[++p2] = v;
  }
  p1 = min(p1, h);
  p2 = min(p2, t);
  if (p1 + p2 + p3 < h + t) {
    for (int i = hd[y]; i; i = nx[i]) v2[to[i]] = 0;
    return 0;
  }
  printf("YES\n%d %d\n", x, y);
  int nw = 0;
  for (int i = 1; i <= p1; i++) printf("%d ", s1[i]);
  while (p1 < h) {
    printf("%d ", s3[++nw]);
    p1++;
  }
  printf("\n");
  for (int i = 1; i <= p2; i++) printf("%d ", s2[i]);
  while (p2 < t) {
    printf("%d ", s3[++nw]);
    p2++;
  }
  printf("\n");
  return 1;
}
void sol() {
  for (int x = 1; x <= n; x++)
    if (du[x] >= h + 1) {
      p1 = 0;
      for (int i = hd[x]; i; i = nx[i]) {
        int y = to[i];
        v1[y] = 1;
      }
      for (int i = hd[x]; i; i = nx[i]) {
        int y = to[i];
        if (du[y] < t + 1) continue;
        if (find2(x, y)) return;
      }
      for (int i = hd[x]; i; i = nx[i]) v1[to[i]] = 0;
    }
  printf("NO\n");
}
int main() {
  memset(v1, 0, sizeof(v1));
  memset(v2, 0, sizeof(v2));
  memset(hd, 0, sizeof(hd));
  memset(nx, 0, sizeof(nx));
  memset(du, 0, sizeof(du));
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    du[x]++;
    du[y]++;
    ad(x, y);
    ad(y, x);
  }
  sol();
  return 0;
}
