#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, h, t;
int a[2 * N], b[2 * N];
vector<int> g[N];
int used[N];
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", a + i, b + i);
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  for (int i = 0; i < m; ++i) {
    a[i + m] = b[i];
    b[i + m] = a[i];
  }
  int it = 0;
  for (int i = 0; i < 2 * m; ++i) {
    if (g[a[i]].size() >= h + 1 && g[b[i]].size() >= t + 1) {
      int good = 0;
      if (g[a[i]].size() >= h + t + 2 || g[b[i]].size() >= h + t + 2) good = 1;
      if (!good) {
        ++it;
        int cnt = 0;
        for (int j = 0; j < g[a[i]].size(); ++j) {
          int u = g[a[i]][j];
          if (used[u] != it) {
            used[u] = it;
            cnt++;
          }
        }
        for (int j = 0; j < g[b[i]].size(); ++j) {
          int u = g[b[i]][j];
          if (used[u] != it) {
            used[u] = it;
            cnt++;
          }
        }
        if (cnt >= h + t + 2) good = 1;
      }
      if (good) {
        puts("YES");
        printf("%d %d\n", a[i], b[i]);
        for (int ii = 1; ii <= n; ++ii) used[ii] = 0;
        for (int j = 0; j < g[a[i]].size(); ++j) {
          int u = g[a[i]][j];
          used[u] |= 1;
        }
        for (int j = 0; j < g[b[i]].size(); ++j) {
          int u = g[b[i]][j];
          used[u] |= 2;
        }
        used[a[i]] = 0;
        used[b[i]] = 0;
        vector<int> b, c;
        for (int ii = 1; ii <= n; ++ii) {
          if (used[ii] == 1)
            b.push_back(ii);
          else if (used[ii] == 2)
            c.push_back(ii);
        }
        for (int ii = 1; ii <= n; ++ii) {
          if (used[ii] == 3)
            if (b.size() < h)
              b.push_back(ii);
            else
              c.push_back(ii);
        }
        for (int j = 0; j < h; ++j) {
          printf("%d%c", b[j], " \n"[j == h - 1]);
        }
        for (int j = 0; j < t; ++j) {
          printf("%d%c", c[j], " \n"[j == t - 1]);
        }
        return 0;
      }
    }
  }
  puts("NO");
  return 0;
}
