#include <bits/stdc++.h>
using namespace std;
vector<int> g[100100];
int d[100100];
int main() {
  int m, n, h, t;
  scanf("%d%d%d%d", &n, &m, &h, &t);
  memset(d, 0, sizeof(d));
  for (int i = 1; i <= n; i++) g[i].clear();
  while (m--) {
    int v, u;
    scanf("%d%d", &v, &u);
    d[v]++;
    d[u]++;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int u = 1; u <= n; u++) {
    if (d[u] > h) {
      for (int i = 0; i < d[u]; i++) {
        int v = g[u][i];
        if (d[v] > t) {
          int f[100010];
          for (int j = 1; j <= n; j++) f[j] = 0;
          int x = 0;
          for (int j = 0; j < d[v]; j++) f[g[v][j]] = 1;
          for (int j = 0; j < d[u]; j++)
            if (f[g[u][j]]) x++;
          if (h + t + x + 2 <= d[v] + d[u]) {
            int ff[100010];
            for (int j = 1; j <= n; j++) ff[j] = 0;
            printf("YES\n");
            printf("%d %d\n", u, v);
            int first = 1;
            int tt = 0;
            for (int j = 0; tt < h && j < d[u]; j++)
              if (g[u][j] != v && !f[g[u][j]]) {
                tt++;
                if (first) {
                  printf("%d", g[u][j]);
                  first = 0;
                } else {
                  printf(" %d", g[u][j]);
                }
              }
            if (tt < h)
              for (int j = 0; j < d[u] && tt < h; j++)
                if (g[u][j] != v && f[g[u][j]]) {
                  tt++;
                  printf(" %d", g[u][j]);
                  ff[g[u][j]] = 1;
                }
            printf("\n");
            first = 1;
            tt = 0;
            for (int j = 0; tt < t && j < d[v]; j++)
              if (g[v][j] != u && !ff[g[v][j]]) {
                tt++;
                if (first) {
                  printf("%d", g[v][j]);
                  first = 0;
                } else {
                  printf(" %d", g[v][j]);
                }
              }
            printf("\n");
            return 0;
          }
        }
      }
    }
  }
  printf("NO\n");
  return 0;
}
