#include <bits/stdc++.h>
using namespace std;
int n, m, h, t;
vector<int> v[100003], x, y;
bool ok[2][100003], vis[100003];
int main() {
  cin >> n >> m >> h >> t;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
    x.push_back(a);
    x.push_back(b);
    y.push_back(b);
    y.push_back(a);
  }
  for (int i = 0; i < 2 * m; i++) {
    if (v[x[i]].size() <= h || v[y[i]].size() <= t) continue;
    int CNT = 0;
    for (int j = 0; j < v[x[i]].size(); j++) {
      if (v[x[i]][j] == y[i]) continue;
      if (!vis[v[x[i]][j]]) CNT++;
      vis[v[x[i]][j]] = 1;
      if (CNT >= h + t) break;
    }
    for (int j = 0; j < v[y[i]].size(); j++) {
      if (v[y[i]][j] == x[i]) continue;
      if (!vis[v[y[i]][j]]) CNT++;
      vis[v[y[i]][j]] = 1;
      if (CNT >= h + t) break;
    }
    if (CNT < h + t) {
      for (int j = 0; j < v[x[i]].size(); j++) vis[v[x[i]][j]] = 0;
      for (int j = 0; j < v[y[i]].size(); j++) vis[v[y[i]][j]] = 0;
      continue;
    }
    cout << "YES\n" << x[i] + 1 << ' ' << y[i] + 1 << endl;
    for (int j = 0; j < v[x[i]].size(); j++)
      if (v[x[i]][j] != y[i]) ok[0][v[x[i]][j]] = 1;
    for (int j = 0; j < v[y[i]].size(); j++)
      if (v[y[i]][j] != x[i]) ok[1][v[y[i]][j]] = 1;
    vector<int> a, b, c;
    for (int j = 0; j < n; j++) {
      if (ok[0][j] && !ok[1][j]) a.push_back(j);
      if (!ok[0][j] && ok[1][j]) b.push_back(j);
      if (ok[0][j] && ok[1][j]) c.push_back(j);
    }
    while (a.size() < h && c.size()) {
      a.push_back(c.back());
      c.pop_back();
    }
    while (b.size() < t && c.size()) {
      b.push_back(c.back());
      c.pop_back();
    }
    for (int j = 0; j < h; j++) printf("%d ", a[j] + 1);
    cout << endl;
    for (int j = 0; j < t; j++) printf("%d ", b[j] + 1);
    return 0;
  }
  cout << "NO";
}
