#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, m, h, t, vis[N];
vector<int> H, T, e[N];
bool check(int u, int v) {
  if (((int)(e[u]).size()) < h + 1 || ((int)(e[v]).size()) < t + 1)
    return false;
  for (int i = (0), I = (min(h + t + 1, ((int)(e[u]).size()))); i < I; ++i) {
    int x = e[u][i];
    vis[x] = u;
  }
  vector<int> C;
  H.clear(), T.clear();
  for (int i = (0), I = (min(h + t + 1, ((int)(e[v]).size()))); i < I; ++i) {
    int x = e[v][i];
    if (x == u) continue;
    if (vis[x] == u)
      C.push_back(x);
    else
      T.push_back(x);
    vis[x] = v;
  }
  for (int i = (0), I = (min(h + t + 1, ((int)(e[u]).size()))); i < I; ++i) {
    int x = e[u][i];
    if (x == v) continue;
    if (vis[x] != v) H.push_back(x);
  }
  for (int i = (0), I = (((int)(C).size())); i < I; ++i)
    if (((int)(H).size()) < h) {
      H.push_back(C[i]);
    } else if (((int)(T).size()) < t) {
      T.push_back(C[i]);
    } else
      break;
  return ((int)(H).size()) >= h && ((int)(T).size()) >= t;
}
void solve() {
  for (int u = (1), I = (n + 1); u < I; ++u) {
    for (int i = (0), I = (((int)(e[u]).size())); i < I; ++i) {
      int v = e[u][i];
      if (check(u, v)) {
        puts("YES");
        printf("%d %d\n", u, v);
        for (int i = (0), I = (h); i < I; ++i)
          printf("%d%c", H[i], " \n"[i == h - 1]);
        for (int i = (0), I = (t); i < I; ++i)
          printf("%d%c", T[i], " \n"[i == t - 1]);
        return;
      }
    }
  }
  puts("NO");
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = (0), I = (m); i < I; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v), e[v].push_back(u);
  }
  solve();
  return 0;
}
