#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edges;
vector<vector<int> > ne;
int main() {
  int i, j;
  int n, m, h, t;
  scanf("%d %d %d %d", &n, &m, &h, &t);
  bool sw = (h > t);
  if (sw) {
    swap(h, t);
  }
  edges.resize(m);
  ne.resize(n + 1);
  for (i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    ne[a].push_back(b);
    ne[b].push_back(a);
    edges[i] = make_pair(min(a, b), max(a, b));
  }
  for (i = 1; i <= n; ++i) {
    sort(ne[i].begin(), ne[i].end());
  }
  sort(edges.begin(), edges.end());
  for (i = 0; i < m; ++i) {
    int a, b;
    a = edges[i].first;
    b = edges[i].second;
    if (ne[a].size() > ne[b].size()) swap(a, b);
    if (ne[a].size() > h && ne[b].size() > t) {
      int ca, cb;
      ca = cb = 0;
      int canOverlap = ne[a].size() + ne[b].size() - 2 - h - t;
      vector<int> va, vb, vab;
      while (ca < ne[a].size() && cb < ne[b].size()) {
        if (ne[a][ca] == b) {
          ++ca;
          continue;
        }
        if (ne[b][cb] == a) {
          ++cb;
          continue;
        }
        if (ne[a][ca] < ne[b][cb]) {
          va.push_back(ne[a][ca++]);
        } else if (ne[b][cb] < ne[a][ca]) {
          vb.push_back(ne[b][cb++]);
        } else {
          canOverlap--;
          if (canOverlap < 0) break;
          vab.push_back(ne[a][ca]);
          ca++;
          cb++;
        }
      }
      if (ca < ne[a].size() && cb < ne[b].size()) continue;
      for (; ca < ne[a].size(); ++ca) {
        va.push_back(ne[a][ca]);
      }
      for (; cb < ne[b].size(); ++cb) {
        vb.push_back(ne[b][cb]);
      }
      if (sw) {
        swap(h, t);
        swap(va, vb);
        swap(a, b);
      }
      printf("YES\n");
      printf("%d %d\n", a, b);
      while (va.size() < h) {
        va.push_back(vab.back());
        vab.pop_back();
      }
      while (vb.size() < t) {
        vb.push_back(vab.back());
        vab.pop_back();
      }
      printf("%d", va[0]);
      for (i = 1; i < h; ++i) {
        printf(" %d", va[i]);
      }
      printf("\n");
      printf("%d", vb[0]);
      for (i = 1; i < t; ++i) {
        printf(" %d", vb[i]);
      }
      return 0;
    }
  }
  printf("NO\n");
  return 0;
}
