#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g(100001);
int n, m, h, t, f[100001], c = 0;
void solvePlzz(int u, int v) {
  vector<int> ue, ve, comm;
  for (int i = 0, s = h + t; i < g[u].size() and s; i++, s--)
    if (g[u][i] != v) f[g[u][i]] = c;
  for (int i = 0, s = h + t; i < g[v].size() and s; i++, s--)
    if (g[v][i] != u) {
      if (f[g[v][i]] == c)
        comm.push_back(g[v][i]), f[g[v][i]] = -c;
      else
        ve.push_back(g[v][i]);
    }
  for (int i = 0, s = h + t; i < g[u].size() and s; i++, s--)
    if (f[g[u][i]] == c) ue.push_back(g[u][i]);
  while (ve.size() < h and comm.size())
    ve.push_back(comm.back()), comm.pop_back();
  while (ue.size() < t and comm.size())
    ue.push_back(comm.back()), comm.pop_back();
  if (ve.size() < h or ue.size() < t) return;
  cout << "YES" << endl << v << " " << u << endl;
  for (int i = 0; i < h; i++) cout << ve[i] << " ";
  cout << endl;
  for (int i = 0; i < t; i++) cout << ue[i] << " ";
  cout << endl;
  exit(0);
}
int main() {
  cin >> n >> m >> h >> t;
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= 100001; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      c++;
      solvePlzz(i, g[i][j]);
    }
  }
  cout << "NO";
}
