#include <bits/stdc++.h>
using namespace std;
set<int> E[100005];
vector<int> L[100005];
int True = 0;
int vst[100005];
int main() {
  int n, m, h, t, i, u, v, _h, _t, j, k;
  cin >> n >> m >> h >> t;
  for (i = 0; i < (m); i++) {
    scanf("%d%d", &u, &v);
    L[u].push_back(v);
    L[v].push_back(u);
    E[u].insert(v);
    E[v].insert(u);
  }
  for (i = (1); i <= (n); i++) {
    u = i;
    if (((int)(E[u]).size()) < h + 1) continue;
    for (j = 0; j < (((int)(L[i]).size())); j++) {
      v = L[i][j];
      if (((int)(E[u]).size()) + ((int)(E[v]).size()) < h + t + 2) continue;
      if (((int)(E[v]).size()) < t + 1) continue;
      bool sp = 0;
      if (((int)(E[u]).size()) > ((int)(E[v]).size())) {
        swap(u, v);
        sp = 1;
      }
      set<int>::iterator it = E[u].begin();
      _h = 0;
      vector<int> cmn;
      True++;
      for (k = 0; k < (((int)(L[u]).size())); k++) vst[L[u][k]] = True;
      for (k = 0; k < (((int)(L[v]).size())); k++) {
        if (vst[L[v][k]] == True) {
          _h++;
          cmn.push_back(L[v][k]);
        }
      }
      if (sp) swap(u, v);
      if (((int)(E[u]).size()) + ((int)(E[v]).size()) - _h < h + t + 2)
        continue;
      printf("YES\n");
      printf("%d %d\n", u, v);
      it = E[u].begin();
      while (it != E[u].end()) {
        if (E[v].find(*it) == E[v].end()) {
          if (*it == v) {
            it++;
            continue;
          }
          h--;
          printf("%d ", *it);
        }
        if (!h) break;
        it++;
      }
      while (h--) {
        printf("%d ", cmn[((int)(cmn).size()) - 1]);
        cmn.pop_back();
      }
      printf("\n");
      it = E[v].begin();
      while (it != E[v].end()) {
        if ((E[u].find(*it) == E[u].end())) {
          if (*it == u) {
            it++;
            continue;
          }
          t--;
          printf("%d ", *it);
        }
        if (!t) break;
        it++;
      }
      while (t--) {
        printf("%d ", cmn[((int)(cmn).size()) - 1]);
        cmn.pop_back();
      }
      printf("\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
