#include <bits/stdc++.h>
using namespace std;
vector<int> edge[105000], head;
bool vis[105000];
int n, m, h, t;
bool solve(int hi, int ti) {
  int hnum = 0, tnum = 0;
  memset(vis, false, sizeof(vis));
  for (int i = 0; i < edge[hi].size(); i++)
    if (edge[hi][i] != ti) {
      hnum++;
      vis[edge[hi][i]] = true;
    }
  for (int i = 0; i < edge[ti].size(); i++)
    if (edge[ti][i] != hi)
      if (!vis[edge[ti][i]])
        tnum++;
      else if (hnum > h)
        vis[edge[ti][i]] = false, tnum++, hnum--;
  if (hnum >= h && tnum >= t) {
    puts("YES");
    printf("%d %d\n", hi, ti);
    for (int i = 0; i < edge[hi].size() && h; i++)
      if (vis[edge[hi][i]]) {
        printf("%d ", edge[hi][i]);
        h--;
      }
    puts("");
    for (int i = 0; i < edge[ti].size() && t; i++)
      if (!vis[edge[ti][i]] && edge[ti][i] != hi) {
        printf("%d ", edge[ti][i]);
        t--;
      }
    return true;
  }
  return false;
}
bool find() {
  for (int i = 0; i < head.size(); i++)
    for (int j = 0; j < edge[head[i]].size(); j++) {
      int hi = head[i];
      int ti = edge[hi][j];
      if (edge[ti].size() > t)
        if (solve(hi, ti)) return true;
    }
  return false;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (edge[i].size() > h) head.push_back(i);
  if (!find()) puts("NO");
  return 0;
}
