#include <bits/stdc++.h>
using namespace std;
int n, m, h, t;
int vst[100010], rev[100010], che[100010];
vector<int> G[100010];
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int u = 1; u <= n; u++) {
    if ((int)((G[u]).size()) <= h) continue;
    for (__typeof((G[u]).begin()) it = (G[u]).begin(); it != (G[u]).end(); it++)
      vst[*it] = 1;
    for (__typeof((G[u]).begin()) it = (G[u]).begin(); it != (G[u]).end();
         it++) {
      if ((int)((G[*it]).size()) <= t) continue;
      int v = *it;
      int cnt = 0;
      int rem = (int)((G[u]).size()) - h - 1;
      for (int i = 0; cnt < t && i < (int)((G[v]).size()); i++) {
        int x = G[v][i];
        if (x == u) continue;
        if (rem && vst[x])
          rem--, che[x] = 1, rev[cnt++] = x;
        else if (!vst[x])
          rev[cnt++] = x;
      }
      if (cnt == t) {
        printf("YES\n%d %d\n", u, v);
        int c = 0;
        for (__typeof((G[u]).begin()) it2 = (G[u]).begin(); it2 != (G[u]).end();
             it2++) {
          if (che[*it2] || *it2 == v) continue;
          printf("%d ", *it2);
          if ((++c) == h) break;
        }
        puts("");
        for (int i = 0; i < cnt; i++) printf("%d ", rev[i]);
        puts("");
        return 0;
      }
      for (int i = 0; i < cnt; i++) che[rev[i]] = 0;
    }
    for (__typeof((G[u]).begin()) it = (G[u]).begin(); it != (G[u]).end(); it++)
      vst[*it] = 0;
  }
  puts("NO");
}
