#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100002];
int ed1[100002];
int ed2[100002];
int sames[100002];
int n, m, h, t;
void sols(int hd, int tl) {
  printf("YES\n%d %d\n", hd, tl);
  for (int j = 0; j < edge[tl].size(); j++) sames[edge[tl][j]] = -1;
  int called = 0;
  for (int j = 0; j < edge[hd].size(); j++) {
    if (sames[edge[hd][j]] >= 0 && edge[hd][j] != tl) {
      printf("%d", edge[hd][j]);
      called++;
      if (h - called) {
        printf(" ");
      } else {
        printf("\n");
        break;
      }
    }
  }
  if (h - called) {
    for (int j = 0; j < edge[hd].size(); j++) {
      if (sames[edge[hd][j]] == -1 && edge[hd][j] != tl) {
        printf("%d", edge[hd][j]);
        sames[edge[hd][j]] = 0;
        called++;
        if (h - called) {
          printf(" ");
        } else {
          printf("\n");
          break;
        }
      }
    }
  }
  called = 0;
  for (int j = 0; j < edge[tl].size(); j++) {
    if (sames[edge[tl][j]] < 0 && edge[tl][j] != hd) {
      printf("%d", edge[tl][j]);
      called++;
      if (t - called) {
        printf(" ");
      } else {
        printf("\n");
        break;
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &ed1[i], &ed2[i]);
    edge[ed1[i]].push_back(ed2[i]);
    edge[ed2[i]].push_back(ed1[i]);
  }
  for (int i = 1; i <= m; i++) {
    if (edge[ed1[i]].size() > h && edge[ed2[i]].size() > t) {
      int samec = 0;
      for (int j = 0; j < edge[ed1[i]].size(); j++)
        sames[edge[ed1[i]][j]] = i + i;
      for (int j = 0; j < edge[ed2[i]].size(); j++)
        if (sames[edge[ed2[i]][j]] == i + i) samec++;
      if (edge[ed1[i]].size() + edge[ed2[i]].size() - 2 - samec >= h + t) {
        sols(ed1[i], ed2[i]);
        return 0;
      }
    }
    if (edge[ed1[i]].size() > t && edge[ed2[i]].size() > h) {
      int samec = 0;
      for (int j = 0; j < edge[ed1[i]].size(); j++)
        sames[edge[ed1[i]][j]] = i + i + 1;
      for (int j = 0; j < edge[ed2[i]].size(); j++)
        if (sames[edge[ed2[i]][j]] == i + i + 1) samec++;
      if (edge[ed1[i]].size() + edge[ed2[i]].size() - 2 - samec >= h + t) {
        sols(ed2[i], ed1[i]);
        return 0;
      }
    }
  }
  printf("NO\n");
  return 0;
}
