#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 10;
int N, M, H, T;
int deg[MAX_N];
vector<vector<int> > G(MAX_N);
bool is_hydra(int a, int b) {
  if (deg[a] < H + 1) return false;
  if (deg[b] < T + 1) return false;
  vector<int> h(N + 10);
  int common = 0;
  for (int i = 0; i < G[a].size(); ++i) h[G[a][i]]++;
  for (int i = 0; i < G[b].size(); ++i)
    if (h[G[b][i]] == 1) {
      common++;
      h[G[b][i]]++;
    }
  if (deg[a] + deg[b] - common >= H + T + 2) {
    cout << "YES" << endl;
    cout << a << " " << b << endl;
    int c = 0;
    for (int i = 0; i < G[a].size(); ++i) {
      if (c == H) break;
      if (G[a][i] == b) continue;
      if (h[G[a][i]] == 2) continue;
      cout << G[a][i] << " ";
      c++;
    }
    if (c != H) {
      for (int i = 0; i < G[a].size(); ++i) {
        if (c == H) break;
        if (h[G[a][i]] != 2) continue;
        h[G[a][i]]++;
        cout << G[a][i] << " ";
        c++;
      }
    }
    cout << endl;
    c = 0;
    for (int i = 0; i < G[b].size(); ++i) {
      if (c == T) break;
      if (G[b][i] == a) continue;
      if (h[G[b][i]] != 3) {
        cout << G[b][i] << " ";
        c++;
      }
    }
    cout << endl;
    return true;
  }
  return false;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> N >> M >> H >> T;
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < G[i].size(); ++j) {
      if (is_hydra(i, G[i][j])) return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
