#include <bits/stdc++.h>
using namespace std;
vector<int> heads, tails;
set<int>::iterator it;
vector<int> vec[100100], vaux;
set<int> svec[100100];
int marked[100100], marked2[100100];
int N, M, h, t, i, j, k, p, q, cnt;
int main() {
  scanf("%d %d %d %d", &N, &M, &h, &t);
  while (M--) {
    scanf("%d %d", &i, &j);
    vec[i].push_back(j);
    svec[i].insert(j);
    vec[j].push_back(i);
    svec[j].insert(i);
  }
  cnt = 0;
  for (i = 1; i <= N; i++) {
    if (vec[i].size() < h + 1) continue;
    for (k = 0; k < vec[i].size(); k++) marked[vec[i][k]] = i;
    for (k = 0; k < vec[i].size(); k++) {
      j = vec[i][k];
      if (vec[j].size() < t + 1) continue;
      heads.clear();
      tails.clear();
      vaux.clear();
      cnt++;
      if (vec[i].size() < vec[j].size()) {
        for (p = 0; p < vec[i].size() && heads.size() < h; p++)
          if (p != k) {
            if (svec[j].find(vec[i][p]) == svec[j].end()) {
              heads.push_back(vec[i][p]);
              marked2[vec[i][p]] = cnt;
            } else {
              vaux.push_back(vec[i][p]);
            }
          }
        if (heads.size() < h && heads.size() + vaux.size() >= h) {
          for (p = 0; heads.size() < h; p++) {
            heads.push_back(vaux[p]);
            marked2[vaux[p]] = cnt;
          }
        }
        if (heads.size() == h) {
          for (p = 0; p < vec[j].size() && tails.size() < t; p++)
            if (vec[j][p] != i && marked2[vec[j][p]] != cnt) {
              tails.push_back(vec[j][p]);
            }
        }
      } else {
        for (p = 0; p < vec[j].size() && tails.size() < t; p++)
          if (vec[j][p] != i) {
            if (marked[vec[j][p]] != i) {
              tails.push_back(vec[j][p]);
              marked2[vec[j][p]] = cnt;
            } else {
              vaux.push_back(vec[j][p]);
            }
          }
        if (tails.size() < t && tails.size() + vaux.size() >= t) {
          for (p = 0; tails.size() < t; p++) {
            tails.push_back(vaux[p]);
            marked2[vaux[p]] = cnt;
          }
        }
        if (tails.size() == t) {
          for (p = 0; p < vec[i].size() && heads.size() < h; p++)
            if (p != k && marked2[vec[i][p]] != cnt) {
              heads.push_back(vec[i][p]);
            }
        }
      }
      if (heads.size() == h && tails.size() == t) {
        printf("YES\n");
        printf("%d %d\n", i, j);
        for (p = 0; p < h; p++) {
          printf("%d ", heads[p]);
        }
        printf("\n");
        for (p = 0; p < t; p++) {
          printf("%d ", tails[p]);
        }
        printf("\n");
        return 0;
      }
    }
  }
  printf("NO\n");
  return 0;
}
