#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 10;
pair<int, int> edge[maxn];
int mark[maxn];
vector<int> graph[maxn];
vector<int> adU, adV, com;
int n, m, t, h;
void input() {
  cin >> n >> m >> h >> t;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    edge[i].first = u, edge[i].second = v;
    if (graph[v].size() < 300) graph[v].push_back(u);
    if (graph[u].size() < 300) graph[u].push_back(v);
  }
}
void add(int u, int v) {
  for (auto &x : graph[u])
    if (x != v) mark[x] = 1;
  for (auto &x : graph[v])
    if (x != u) {
      if (mark[x])
        mark[x] = 3;
      else
        mark[x] = 2;
    }
}
void reset(int u, int v) {
  for (auto &x : graph[u]) mark[x] = 0;
  for (auto &x : graph[v]) mark[x] = 0;
  adU.clear();
  adV.clear();
  com.clear();
}
void make(int u, int v) {
  for (auto &x : graph[u])
    if (mark[x] == 1) adU.push_back(x);
  for (auto &x : graph[v])
    if (mark[x] == 2)
      adV.push_back(x);
    else if (mark[x] == 3)
      com.push_back(x);
}
void check(int u, int v) {
  add(u, v);
  make(u, v);
  while (adU.size() < h) {
    if (com.empty()) break;
    adU.push_back(com.back());
    com.pop_back();
  }
  while (adV.size() < t) {
    if (com.empty()) break;
    adV.push_back(com.back());
    com.pop_back();
  }
  if (adU.size() >= h && adV.size() >= t) {
    cout << "YES\n";
    cout << u + 1 << " " << v + 1 << endl;
    for (int i = 0; i < h; i++) cout << adU[i] + 1 << " ";
    cout << endl;
    for (int i = 0; i < t; i++) cout << adV[i] + 1 << " ";
    exit(0);
  }
  reset(u, v);
}
int main() {
  input();
  for (int i = 0; i < m; i++) {
    check(edge[i].first, edge[i].second);
    check(edge[i].second, edge[i].first);
  }
  cout << "NO";
  return 0;
}
