#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 10;
struct edge {
  int a;
  int b;
};
int n, m, h, t;
vector<int> g[MAXN];
vector<edge> e;
char u[MAXN];
bool check(int a, int b) {
  int cnt1 = g[a].size() - 1;
  int cnt2 = g[b].size() - 1;
  int cnt_u = 0;
  for (int i = 0; i < g[a].size(); ++i) {
    int to = g[a][i];
    if (g[a][i] != b) u[g[a][i]]++;
  }
  for (int i = 0; i < g[b].size(); ++i) {
    int to = g[b][i];
    if (g[b][i] != a) {
      u[g[b][i]]++;
      if (u[g[b][i]] == 2) cnt_u++;
    }
  }
  for (int i = 0; i < g[a].size(); ++i) u[g[a][i]] = 0;
  for (int i = 0; i < g[b].size(); ++i) u[g[b][i]] = 0;
  cnt1 -= cnt_u;
  cnt2 -= cnt_u;
  cnt_u -= (t - cnt2);
  if (h - cnt1 > cnt_u)
    return false;
  else
    return true;
}
void get_gidra(int a, int b) {
  cout << "YES" << endl;
  cout << a + 1 << " " << b + 1 << endl;
  int H = h;
  int T = t;
  vector<int> head;
  vector<int> tail;
  for (int i = 0; i < g[a].size(); ++i)
    if (g[a][i] != b) u[g[a][i]]++;
  for (int i = 0; i < g[b].size() && T; ++i) {
    if (g[b][i] == a) continue;
    u[g[b][i]]++;
    if (u[g[b][i]] != 2) {
      tail.push_back(g[b][i] + 1);
      T--;
    }
  }
  for (int i = 0; i < g[b].size() && T; ++i)
    if (u[g[b][i]] == 2) {
      u[g[b][i]] = 3;
      tail.push_back(g[b][i] + 1);
      T--;
    }
  for (int i = 0; i < g[a].size() && H; ++i) {
    if (u[g[a][i]] != 3) {
      if (g[a][i] == b) continue;
      head.push_back(g[a][i] + 1);
      H--;
    }
  }
  for (int i = 0; i < g[a].size(); ++i) u[g[a][i]] = 0;
  for (int i = 0; i < g[b].size(); ++i) u[g[b][i]] = 0;
  for (int i = 0; i < head.size(); ++i) cout << head[i] << " ";
  cout << endl;
  for (int i = 0; i < tail.size(); ++i) cout << tail[i] << " ";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> h >> t;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
    e.push_back({x, y});
    e.push_back({y, x});
  }
  for (int i = 0; i < e.size(); ++i) {
    int x = e[i].a, y = e[i].b;
    if (g[x].size() < h + 1 || g[y].size() < t + 1) continue;
    if (g[x].size() >= h + t + 1 || g[y].size() >= h + t + 1) {
      get_gidra(x, y);
      return 0;
    }
    if (check(x, y)) {
      get_gidra(x, y);
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
