#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int n, m, h, t, a, b, c;
vector<vector<int> > g;
bool vis[N];
void dfs(int u) {
  vis[u] = 1;
  if (a != -1) return;
  set<int> s;
  for (int i = 0; i < g[u].size(); i++) s.insert(g[u][i]);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (g[u].size() >= h + 1 && g[v].size() >= t + 1) {
      int ch = g[u].size() - 1, ct = g[v].size() - 1, cc = 0;
      for (int j = 0, x; j < g[v].size(); j++) {
        x = g[v][j];
        if (x != u && s.find(x) != s.end()) {
          ch--;
          ct--;
          cc++;
        }
      }
      c = cc;
      while (ch < h && cc > 0) ch++, cc--;
      while (ct < t && cc > 0) ct++, cc--;
      if (ch >= h && ct >= t) {
        a = u, b = g[u][i];
        return;
      }
    }
    if (!vis[g[u][i]]) dfs(g[u][i]);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  scanf("%d%d%d%d", &n, &m, &h, &t);
  g.resize(n + 1);
  for (int i = 0, a, b; i < m; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  a = -1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
    if (a != -1) break;
  }
  if (a == -1) {
    puts("NO");
    return 0;
  }
  puts("YES");
  printf("%d %d\n", a, b);
  set<int> s, s2;
  vector<int> v;
  for (int i = 0; i < g[a].size(); i++)
    if (g[a][i] != b) s.insert(g[a][i]);
  for (int i = 0; i < g[b].size(); i++)
    if (g[b][i] != a && s.find(g[b][i]) != s.end())
      s2.insert(g[b][i]);
    else if (g[b][i] != a)
      v.push_back(g[b][i]);
  for (int i = 0; i < g[a].size() && h; i++)
    if (g[a][i] != b && s2.find(g[a][i]) == s2.end()) {
      h--;
      printf("%d ", g[a][i]);
    }
  for (set<int>::iterator it = s2.begin(); it != s2.end(); it++) {
    if (h > 0) {
      h--;
      printf("%d ", *it);
    } else
      v.push_back(*it);
  }
  puts("");
  for (int i = 0; i < t; i++) printf("%d ", v[i]);
  puts("");
  return 0;
}
