#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
vector<int> e[100005];
vector<pair<int, int> > edge;
int n, m, h, t;
int vis[100005], pp = 0;
vector<int> e_u, e_v;
bool check(int u, int v) {
  if (e[u].size() - 1 < h || e[v].size() - 1 < t) return false;
  vector<int> com;
  pp++;
  for (int i = 0; i < e[u].size(); i++) vis[e[u][i]] = pp;
  int cnt = 0;
  for (int i = 0; i < e[v].size(); i++) {
    cnt += vis[e[v][i]] == pp;
  }
  int a = e[u].size() - 1 - cnt, b = e[v].size() - 1 - cnt;
  int c = max(h - a, 0);
  if (cnt >= c && b + cnt - c >= t) {
    int tot = 0, idx = 0;
    for (int i = 0; i < e[v].size(); i++) {
      if (vis[e[v][i]] == pp) {
        com.push_back(e[v][i]);
        vis[e[v][i]] = -1;
      }
    }
    for (int i = 0; i < e[u].size() && tot < h; i++) {
      if (vis[e[u][i]] == pp && e[u][i] != v) {
        tot++;
        e_u.push_back(e[u][i]);
      }
    }
    while (tot < h) {
      tot++;
      e_u.push_back(com[idx++]);
    }
    tot = 0;
    for (int i = 0; i < e[v].size() && tot < t; i++) {
      if (vis[e[v][i]] != pp && vis[e[v][i]] != -1 && e[v][i] != u) {
        tot++;
        e_v.push_back(e[v][i]);
      }
    }
    while (tot < t) {
      tot++;
      e_v.push_back(com[idx++]);
    }
    return true;
  }
  return false;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
    edge.push_back(make_pair(u, v));
  }
  for (int i = 0; i < m; i++) {
    int u = edge[i].first, v = edge[i].second;
    if (check(u, v)) {
      puts("YES");
      printf("%d %d\n", u, v);
      for (int i = 0; i < e_u.size(); i++) printf("%d ", e_u[i]);
      puts("");
      for (int i = 0; i < e_v.size(); i++) printf("%d ", e_v[i]);
      puts("");
      return 0;
    }
    swap(u, v);
    if (check(u, v)) {
      puts("YES");
      printf("%d %d\n", u, v);
      for (int i = 0; i < e_u.size(); i++) printf("%d ", e_u[i]);
      puts("");
      for (int i = 0; i < e_v.size(); i++) printf("%d ", e_v[i]);
      puts("");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
