#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
int n, m, h, t;
int p, q, r;
int u, v;
int k, d;
bool flag[N];
bool mark[N];
bool both[N];
pair<int, int> edge[2 * N];
int srt[N];
bool cmp(int x, int y) { return (g[x].size() > g[y].size()); }
int presek(int u, int v) {
  int ret = 0, cnt = 0;
  for (auto xt : g[u]) {
    flag[xt] = true;
    cnt++;
    if (cnt > 205) break;
  }
  for (auto xt : g[v]) {
    if (flag[xt]) ret++;
    if (ret > 205) break;
  }
  return ret;
}
void clear(int u, int v) {
  int cnt = 0;
  for (auto xt : g[u]) {
    flag[xt] = false;
    cnt++;
    if (cnt > 205) break;
  }
  flag[u] = flag[v] = false;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
    edge[i] = make_pair(a, b);
    edge[i + m] = make_pair(b, a);
  }
  for (int i = 0; i < 2 * m; i++) {
    u = edge[i].first;
    v = edge[i].second;
    if (g[u].size() < h) continue;
    if (g[v].size() < t) continue;
    p = g[u].size() - 1;
    q = g[v].size() - 1;
    if (q - p >= t) {
      if (p >= h) {
        puts("YES");
        printf("%d %d\n", u, v);
        for (auto xt : g[u]) {
          if (h == 0) break;
          if (xt == v) continue;
          printf("%d ", xt);
          h--;
          mark[xt] = true;
        }
        printf("\n");
        for (auto xt : g[v]) {
          if (t == 0) break;
          if (xt == u) continue;
          if (mark[xt]) continue;
          t--;
          printf("%d ", xt);
        }
        return 0;
      }
      continue;
    }
    r = presek(u, v);
    k = max(0, h - p + r);
    d = max(0, t - q + r);
    if (k + d <= r) {
      puts("YES");
      int cnt = 0;
      for (auto xt : g[v]) {
        if (flag[xt]) {
          both[xt] = true;
          cnt++;
          if (cnt > 205) break;
        }
      }
      printf("%d %d\n", u, v);
      for (auto xt : g[u]) {
        if (h == 0) break;
        if (both[xt]) continue;
        if (xt == v) continue;
        printf("%d ", xt);
        mark[xt] = true;
        h--;
      }
      for (auto xt : g[u]) {
        if (h == 0) break;
        if (!both[xt]) continue;
        printf("%d ", xt);
        mark[xt] = true;
        h--;
      }
      printf("\n");
      for (auto xt : g[v]) {
        if (t == 0) break;
        if (both[xt]) continue;
        if (xt == u) continue;
        if (mark[xt]) continue;
        printf("%d ", xt);
        t--;
      }
      for (auto xt : g[v]) {
        if (t == 0) break;
        if (!both[xt]) continue;
        if (mark[xt]) continue;
        printf("%d ", xt);
        t--;
      }
      return 0;
    }
    clear(u, v);
  }
  printf("NO");
  return 0;
}
