#include <bits/stdc++.h>
const double eps = 1e-19;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const int MAXN = 100005;
using namespace std;
int n, m, h, t;
vector<int> g[MAXN];
bool was[MAXN];
bool posed[MAXN];
vector<int> ansu, ansv;
int count_t;
void panic(int u, int v) {
  memset(was, 0, sizeof was);
  was[u] = true;
  was[v] = true;
  int k = 0;
  sort(g[v].begin(), g[v].end());
  ansu.clear();
  ansv.clear();
  for (int j = 0; j < (int)g[u].size() && k < h; j++) {
    if (g[u][j] == v) continue;
    if (binary_search(g[v].begin(), g[v].end(), g[u][j])) continue;
    k++;
    was[g[u][j]] = true;
    ansu.push_back(g[u][j]);
  }
  for (int j = 0; j < (int)g[u].size() && k < h; j++) {
    if (was[g[u][j]]) continue;
    k++;
    was[g[u][j]] = true;
    ansu.push_back(g[u][j]);
  }
  for (int j = 0; j < (int)g[v].size() && (int)ansv.size() < t; j++) {
    int x = g[v][j];
    if (!was[x]) {
      was[x] = true;
      ansv.push_back(x);
    }
  }
  if ((int)ansu.size() != h || (int)ansv.size() != t) return;
  printf("YES\n%d %d\n", u + 1, v + 1);
  for (int j = 0; j < (int)ansu.size(); j++) printf("%d ", ansu[j] + 1);
  printf("\n");
  for (int j = 0; j < (int)ansv.size(); j++) printf("%d ", ansv[j] + 1);
  exit(0);
}
void proverka(int u, int v) {
  if (count_t > 500000) {
    printf("NO");
    exit(0);
  }
  count_t++;
  if ((int)g[u].size() < h + 1 || (int)g[v].size() < t + 1) {
    return;
  }
  if ((int)g[u].size() >= 2 * (h + t) && (int)g[v].size() > t) {
    panic(u, v);
  }
  memset(was, 0, sizeof was);
  was[u] = true;
  was[v] = true;
  for (int j = 0; j < (int)g[u].size(); j++) {
    was[g[u][j]] = true;
  }
  int k = 0;
  for (int j = 0; j < (int)g[v].size(); j++)
    if (!was[g[v][j]]) k++;
  if (k >= t) {
    panic(u, v);
  } else if ((int)g[u].size() - (t - k) - 1 >= h) {
    panic(u, v);
  }
  return;
}
void dfs(int x, int pr) {
  if (count_t > 600000) {
    printf("NO");
    exit(0);
  }
  count_t++;
  posed[x] = true;
  for (int j = 0; j < (int)g[x].size(); j++) {
    int u = g[x][j];
    if (u == pr) continue;
    proverka(x, u);
    proverka(u, x);
    if (!posed[u]) {
      dfs(u, x);
    }
  }
}
int main() {
  scanf("%d %d %d %d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++) {
    int ta, tb;
    scanf("%d %d", &ta, &tb);
    ta--;
    tb--;
    count_t++;
    g[ta].push_back(tb);
    g[tb].push_back(ta);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (count_t > 600000) {
      printf("NO");
      exit(0);
    }
    if (!posed[i]) dfs(i, -1);
  }
  printf("NO");
  return 0;
}
