#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
const int N = 1e5 + 10;
int n, m, h, t;
int du[N];
int e[N][2];
std::set<int> g[N];
bool bo[N];
int main() {
  int i, t1, tot, cnt;
  std::set<int>::iterator it, ed;
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (i = 0; i < m; i++)
    scanf("%d%d", &e[i][0], &e[i][1]), du[e[i][0]]++, du[e[i][1]]++,
        g[e[i][0]].insert(e[i][1]), g[e[i][1]].insert(e[i][0]);
  for (i = 0; i < m; i++)
    if (du[e[i][0]] > h && du[e[i][1]] > t) {
      cnt = 0;
      for (it = g[e[i][0]].begin(), ed = g[e[i][0]].end(); it != ed; it++)
        if (g[e[i][1]].count((*it))) cnt++;
      if (du[e[i][0]] + du[e[i][1]] - 2 - cnt < h + t) continue;
      puts("YES");
      t1 = h - (du[e[i][0]] - 1 - cnt);
      printf("%d %d\n", e[i][0], e[i][1]);
      for (it = g[e[i][0]].begin(), cnt = tot = 0; tot != h; it++)
        if ((*it) != e[i][1])
          if (g[e[i][1]].count((*it))) {
            if (cnt < t1) cnt++, tot++, printf("%d ", *it), bo[*it] = true;
          } else
            tot++, printf("%d ", *it);
      putchar('\n');
      for (it = g[e[i][1]].begin(), cnt = tot = 0; tot != t; it++)
        if ((*it) != e[i][0] && !bo[*it]) tot++, printf("%d ", *it);
      putchar('\n');
      return 0;
    } else if (du[e[i][1]] > h && du[e[i][0]] > t) {
      cnt = 0;
      for (it = g[e[i][0]].begin(), ed = g[e[i][0]].end(); it != ed; it++)
        if (g[e[i][1]].count((*it))) cnt++;
      if (du[e[i][0]] + du[e[i][1]] - 2 - cnt < h + t) continue;
      puts("YES");
      t1 = h - (du[e[i][1]] - 1 - cnt);
      printf("%d %d\n", e[i][1], e[i][0]);
      for (it = g[e[i][1]].begin(), cnt = tot = 0; tot != h; it++)
        if ((*it) != e[i][0])
          if (g[e[i][0]].count((*it))) {
            if (cnt < t1) cnt++, tot++, printf("%d ", *it), bo[*it] = true;
          } else
            tot++, printf("%d ", *it);
      putchar('\n');
      for (it = g[e[i][0]].begin(), cnt = tot = 0; tot != t; it++)
        if ((*it) != e[i][1] && !bo[*it]) tot++, printf("%d ", *it);
      putchar('\n');
      return 0;
    }
  puts("NO");
  return 0;
}
