#include <bits/stdc++.h>
using namespace std;
int h, t;
vector<vector<int> > graph;
vector<int> lvl;
int edges[100005][2];
int stat[100005];
int check(int u, int v) {
  int len = h + t;
  int ht = 0;
  int tt = 0;
  stat[u] = -1;
  stat[v] = -1;
  int i = 0;
  while (ht < len) {
    int a = graph[u][i++];
    if (a == -1) break;
    if (stat[a] == -1) continue;
    stat[a] = 1;
    ht++;
  }
  i = 0;
  while (tt < t) {
    int a = graph[v][i++];
    if (a == -1) break;
    if (stat[a] == -1) continue;
    if (stat[a] == 1) {
      if (ht > h)
        ht--;
      else
        continue;
    }
    stat[a] = 2;
    tt++;
  }
  if (ht >= h && tt >= t) return 1;
  stat[u] = 0;
  stat[v] = 0;
  i = 0;
  while (ht > 0) {
    int a = graph[u][i++];
    if (stat[a] == 1) {
      ht--;
      stat[a] = 0;
    }
  }
  i = 0;
  while (tt > 0) {
    int a = graph[v][i++];
    if (stat[a] == 2) tt--;
    stat[a] = 0;
  }
  return 0;
}
void print(int n) {
  for (int i = 0; i <= n && h > 0; i++) {
    if (stat[i] == 1) {
      cout << i << " ";
      h--;
    }
  }
  cout << endl;
  for (int i = 0; i <= n && t > 0; i++) {
    if (stat[i] == 2) {
      cout << i << " ";
      t--;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m >> h >> t;
  for (int i = 0; i <= n; i++) {
    lvl.push_back(0);
    graph.push_back(vector<int>());
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
    edges[i][0] = a;
    edges[i][1] = b;
  }
  for (int i = 0; i <= n; i++) {
    graph[i].push_back(-1);
  }
  for (int i = 0; i < m; i++) {
    if (check(edges[i][0], edges[i][1])) {
      cout << "YES" << endl;
      cout << edges[i][0] << " " << edges[i][1] << endl;
      print(n);
      return 0;
    }
    if (check(edges[i][1], edges[i][0])) {
      cout << "YES" << endl;
      cout << edges[i][1] << " " << edges[i][0] << endl;
      print(n);
      return 0;
    }
  }
  cout << "NO" << endl;
}
