#include <bits/stdc++.h>
using namespace std;
int n, m, h, t, i, j, a[100005], b[100005], head, tail, lhead, ltail, k;
int u[100005];
vector<int> g[100005];
void Init() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
}
void print(int x, int y) {
  printf("YES\n");
  printf("%d %d\n", x, y);
  int H, T;
  T = H = 0;
  for (i = 0; i < g[x].size(); i++) {
    if (g[x][i] == y) continue;
    if (u[g[x][i]] == 1) {
      printf("%d ", g[x][i]);
      u[g[x][i]] = 0;
      H++;
    }
    if (H == h) break;
  }
  if (H != h) {
    for (i = 0; i < g[x].size(); i++) {
      if (g[x][i] == y) continue;
      if (u[g[x][i]] == 2) {
        printf("%d ", g[x][i]);
        u[g[x][i]] = 0;
        H++;
      }
      if (H == h) break;
    }
  }
  printf("\n");
  for (i = 0; i < g[y].size(); i++) {
    if (g[y][i] == x) continue;
    if (u[g[y][i]] != 0) {
      printf("%d ", g[y][i]);
      u[g[y][i]] = 0;
      T++;
    }
    if (T == t) break;
  }
  printf("\n");
}
void solve() {
  for (i = 0; i < m; i++) {
    head = a[i];
    tail = b[i];
    if (g[head].size() > h && g[tail].size() > t) {
      k = 0;
      lhead = min((int)g[head].size(), 210);
      for (j = 0; j < lhead; j++) {
        if (g[head][j] == tail) continue;
        u[g[head][j]]++;
        k++;
      }
      ltail = min((int)g[tail].size(), 210);
      for (j = 0; j < ltail; j++) {
        if (g[tail][j] == head) continue;
        if (u[g[tail][j]] == 0) {
          k++;
        }
        u[g[tail][j]]++;
      }
      if (k >= h + t) {
        print(head, tail);
        exit(0);
      }
      for (j = 0; j < lhead; j++) {
        u[g[head][j]] = 0;
      }
      for (j = 0; j < ltail; j++) {
        u[g[tail][j]] = 0;
      }
    }
    head = b[i];
    tail = a[i];
    if (g[head].size() > h && g[tail].size() > t) {
      k = 0;
      lhead = min((int)g[head].size(), 210);
      for (j = 0; j < lhead; j++) {
        if (g[head][j] == tail) continue;
        u[g[head][j]]++;
        k++;
      }
      ltail = min((int)g[tail].size(), 210);
      for (j = 0; j < ltail; j++) {
        if (g[tail][j] == head) continue;
        if (u[g[tail][j]] == 0) {
          k++;
        }
        u[g[tail][j]]++;
      }
      if (k >= h + t) {
        print(head, tail);
        exit(0);
      }
      for (j = 0; j < lhead; j++) {
        u[g[head][j]] = 0;
      }
      for (j = 0; j < ltail; j++) {
        u[g[tail][j]] = 0;
      }
    }
  }
}
int main() {
  Init();
  solve();
  printf("NO\n");
  return 0;
}
