#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200005];
pair<int, int> e[200005];
bool b[200005], c[200005], d[200005];
int child[200005], res1[200005], res2[200005];
int n, m, h, t;
void solve() {
  int u, v, vv, slb, slc, sltrung, hh, tt;
  for (int i = 1; i <= 2 * m; i++) {
    u = e[i].first, v = e[i].second;
    if (child[u] - 1 < h || child[v] - 1 < t) continue;
    slb = child[u] - 1;
    slc = child[v] - 1;
    for (int j = 0; j < (int)adj[u].size(); j++) {
      vv = adj[u][j];
      b[vv] = true;
    }
    sltrung = 0;
    for (int j = 0; j < (int)adj[v].size(); j++) {
      vv = adj[v][j];
      if (b[vv]) sltrung++;
      c[vv] = true;
    }
    hh = h - (slb - sltrung);
    tt = t - (slc - sltrung);
    if (hh + tt > sltrung) {
      for (int j = 0; j < (int)adj[u].size(); j++) {
        vv = adj[u][j];
        b[vv] = false;
      }
      for (int j = 0; j < (int)adj[v].size(); j++) {
        vv = adj[v][j];
        c[vv] = false;
      }
    } else {
      if (hh < 0) {
        hh = h;
        for (int j = 0; j < (int)adj[u].size(); j++) {
          vv = adj[u][j];
          if (vv == v) continue;
          if (b[vv] && (!c[vv])) res1[++res1[0]] = vv, hh--;
          if (!hh) break;
        }
      } else
        for (int j = 0; j < (int)adj[u].size(); j++) {
          vv = adj[u][j];
          if (vv == v) continue;
          if (b[vv] && (!c[vv])) res1[++res1[0]] = vv;
        }
      if (tt < 0) {
        tt = t;
        for (int j = 0; j < (int)adj[v].size(); j++) {
          vv = adj[v][j];
          if (vv == u) continue;
          if ((!b[vv]) && c[vv]) res2[++res2[0]] = vv, tt--;
          if (!tt) break;
        }
      } else
        for (int j = 0; j < (int)adj[v].size(); j++) {
          vv = adj[v][j];
          if (vv == u) continue;
          if ((!b[vv]) && c[vv]) res2[++res2[0]] = vv;
        }
      if (hh)
        for (int j = 0; j < (int)adj[u].size(); j++) {
          vv = adj[u][j];
          if (vv == v) continue;
          if (b[vv] && c[vv]) res1[++res1[0]] = vv, d[vv] = true, hh--;
          if (!hh) break;
        }
      if (tt)
        for (int j = 0; j < (int)adj[v].size(); j++) {
          vv = adj[v][j];
          if (vv == u) continue;
          if (b[vv] && c[vv] && (!d[vv]))
            res2[++res2[0]] = vv, d[vv] = true, tt--;
          if (!tt) break;
        }
      puts("YES");
      printf("%d %d\n", u, v);
      for (int i = 1; i <= res1[0]; i++) printf("%d ", res1[i]);
      printf("\n");
      for (int i = 1; i <= res2[0]; i++) printf("%d ", res2[i]);
      printf("\n");
      return;
    }
  }
  puts("NO");
}
int main() {
  if (0) {
    freopen("a.inp", "r", stdin);
  };
  int u, v;
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    child[u]++;
    adj[v].push_back(u);
    child[v]++;
    e[i].first = u;
    e[i].second = v;
    e[m + i].first = v;
    e[m + i].second = u;
  }
  solve();
}
