#include <bits/stdc++.h>
namespace wxy {
const int N = 1e6 + 5;
int h, t, n, m;
int head[N], edge[N << 1], fail[N << 1], deg[N], tot;
inline void add(int first, int second) {
  edge[++tot] = second;
  fail[tot] = head[first];
  head[first] = tot;
}
bool check = false;
bool vw[N], vis[N], vp[N];
std::vector<int> ansx;
std::vector<int> ansy;
inline bool fuck(bool vis[], int first, int v) {
  int same = 0;
  for (int j = head[v]; j; j = fail[j]) {
    if (vis[edge[j]]) {
      same++;
      vw[edge[j]] = true;
    }
  }
  int cnt = deg[v] - 1 - same;
  int delta = std::max(0, h - (deg[first] - same - 1));
  int pp = same - delta;
  cnt += pp;
  if (cnt >= t) {
    std::cout << "YES" << std::endl;
    int p = std::min(h, deg[first] - same - 1), q = delta;
    int ct = 0;
    for (int k = head[first]; k; k = fail[k]) {
      if (ct < p) {
        if (edge[k] != v && !vw[edge[k]]) {
          ansx.push_back(edge[k]);
          ct++;
        }
      } else
        break;
    }
    ct = 0;
    for (int k = head[first]; k; k = fail[k]) {
      if (ct < q) {
        if (edge[k] != v && vw[edge[k]]) {
          ansx.push_back(edge[k]);
          vp[edge[k]] = true;
          ct++;
        }
      } else
        break;
    }
    ct = 0;
    for (int k = head[v]; k; k = fail[k]) {
      if (ct < t) {
        if (edge[k] != first && !vp[edge[k]]) {
          ct++;
          ansy.push_back(edge[k]);
        }
      } else
        break;
    }
    return true;
  }
  for (int j = head[v]; j; j = fail[j])
    if (vis[edge[j]]) vw[edge[j]] = false;
  return false;
}
inline bool dfs(int first, int v) {
  if (deg[first] - 1 < h || deg[v] < t) return false;
  for (int i = head[first]; i; i = fail[i]) vis[edge[i]] = true;
  if (fuck(vis, first, v)) return true;
  for (int i = head[first]; i; i = fail[i]) vis[edge[i]] = false;
  return false;
}
std::pair<int, int> edg[N];
inline void main() {
  tot = 0;
  scanf("%d%d%d%d", &n, &m, &h, &t);
  if (h < t) {
    check = true;
    std::swap(h, t);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b);
    add(b, a);
    deg[a]++;
    deg[b]++;
    edg[i].first = a;
    edg[i].second = b;
  }
  for (int i = 0; i < m; i++) {
    if (edg[i].first < edg[i].second) std::swap(edg[i].first, edg[i].second);
    if (dfs(edg[i].first, edg[i].second)) {
      int first = edg[i].first, v = edg[i].second;
      if (check) {
        std::cout << v << " " << first;
        puts("");
        for (int i = 0; i < ansy.size(); i++) std::cout << ansy[i] << " ";
        puts("");
        for (int i = 0; i < ansx.size(); i++) std::cout << ansx[i] << " ";
      } else {
        std::cout << first << " " << v;
        puts("");
        for (int i = 0; i < ansx.size(); i++) std::cout << ansx[i] << " ";
        puts("");
        for (int i = 0; i < ansy.size(); i++) std::cout << ansy[i] << " ";
      }
      return;
    }
  }
  std::cout << "NO";
}
}  // namespace wxy
signed main() {
  wxy::main();
  return 0;
}
