#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n, m, H, T, eq[N], with[N];
vector<int> g[N];
pair<int, int> e[N];
bool vis[N];
int main() {
  scanf("%d%d%d%d", &n, &m, &H, &T);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &e[i].first, &e[i].second);
    --e[i].first;
    --e[i].second;
    g[e[i].first].push_back(e[i].second);
    g[e[i].second].push_back(e[i].first);
  }
  bool can = false;
  for (int i = 0; i < m; ++i) {
    int u = e[i].first, v = e[i].second;
    if (((int)g[u].size() - 1 < H || (int)g[v].size() - 1 < T) &&
        ((int)g[v].size() - 1 < H && (int)g[u].size() - 1 < T))
      continue;
    can = true;
    break;
  }
  if (!can) {
    puts("NO");
    return 0;
  }
  for (int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end());
  int id = 0;
  pair<int, int> res = make_pair(-1, -1);
  vector<int> a, b;
  for (int i = 0; i < m; ++i) {
    int u = e[i].first, v = e[i].second;
    ++id;
    if (((int)g[u].size() - 1 < H || (int)g[v].size() - 1 < T) &&
        ((int)g[v].size() - 1 < H && (int)g[u].size() - 1 < T))
      continue;
    if (g[v].size() < g[u].size()) swap(u, v);
    for (size_t j = 0; j < g[u].size(); ++j) {
      int go = g[u][j];
      if (binary_search(g[go].begin(), g[go].end(), v)) {
        ++eq[i];
        with[go] = id;
      }
    }
    for (int it = 0; it < 2; ++it) {
      int withU = (int)g[u].size() - eq[i] - 1;
      int withV = (int)g[v].size() - eq[i] - 1;
      int needH = max(0, H - withU), needT = max(0, T - withV);
      if (eq[i] < needH + needT) {
        swap(u, v);
        continue;
      }
      res = make_pair(u, v);
      for (size_t j = 0; j < g[u].size(); ++j) {
        int go = g[u][j];
        if (go == v) continue;
        if (with[go] == id) {
          if (needH != 0) {
            --needH;
            a.push_back(go);
            vis[go] = true;
          }
        } else
          a.push_back(go);
        if ((int)a.size() == H) break;
      }
      for (size_t j = 0; j < g[v].size(); ++j) {
        int go = g[v][j];
        if (!vis[go] && go != u) b.push_back(go);
        if ((int)b.size() == T) break;
      }
      break;
    }
    if (res.first != -1) break;
  }
  if (res.first == -1)
    puts("NO");
  else {
    printf("YES\n%d %d\n", res.first + 1, res.second + 1);
    for (int i = 0; i < H; ++i) printf("%s%d", i ? " " : "", a[i] + 1);
    puts("");
    for (int i = 0; i < T; ++i) printf("%s%d", i ? " " : "", b[i] + 1);
    puts("");
  }
  return 0;
}
