#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1 << 18;
int N, M, H, T, Deg[MaxN];
vector<int> E[MaxN];
int main(void) {
  cin.sync_with_stdio(0);
  cin >> N >> M >> H >> T;
  for (int i = 0; i < M; i++) {
    int idx, idy;
    cin >> idx >> idy;
    idx--;
    idy--;
    Deg[idx]++;
    Deg[idy]++;
    E[idx].push_back(idy);
    E[idy].push_back(idx);
  }
  for (int i = 0; i < N; i++) sort(E[i].begin(), E[i].end());
  for (int i = 0; i < N; i++)
    for (vector<int>::iterator it = E[i].begin(); it != E[i].end(); it++) {
      if (i == *it) continue;
      if ((Deg[i] < H + 1) || (Deg[*it] < T + 1)) continue;
      bool Hydra = false;
      vector<int> Head, Tail, HeadTail;
      if ((Deg[i] >= H + T + 1) || (Deg[*it] >= H + T + 1))
        Hydra = true;
      else {
        vector<int>::iterator idx = E[i].begin(), idy = E[*it].begin();
        while ((idx != E[i].end()) && (idy != E[*it].end())) {
          if (*idx == *it) {
            idx++;
            continue;
          }
          if (*idy == i) {
            idy++;
            continue;
          }
          if (*idx < *idy) {
            Head.push_back(*idx);
            idx++;
            continue;
          }
          if (*idx > *idy) {
            Tail.push_back(*idy);
            idy++;
            continue;
          }
          if (*idx == *idy) {
            HeadTail.push_back(*idx);
            idx++;
            idy++;
            continue;
          }
        }
        while (idx != E[i].end()) {
          Head.push_back(*idx);
          idx++;
        }
        while (idy != E[*it].end()) {
          Tail.push_back(*idy);
          idy++;
        }
        int Need = 0;
        if (Head.size() < H) Need += H - Head.size();
        if (Tail.size() < T) Need += T - Tail.size();
        if (Need <= HeadTail.size()) Hydra = true;
      }
      if (Hydra) {
        cout << "YES" << endl;
        cout << i + 1 << " " << *it + 1 << endl;
        if ((Head.empty()) && (HeadTail.empty())) {
          vector<int>::iterator idx = E[i].begin(), idy = E[*it].begin();
          while ((idx != E[i].end()) && (idy != E[*it].end())) {
            if (*idx == *it) {
              idx++;
              continue;
            }
            if (*idy == i) {
              idy++;
              continue;
            }
            if (*idx < *idy) {
              Head.push_back(*idx);
              idx++;
              continue;
            }
            if (*idx > *idy) {
              Tail.push_back(*idy);
              idy++;
              continue;
            }
            if (*idx == *idy) {
              HeadTail.push_back(*idx);
              idx++;
              idy++;
              continue;
            }
          }
          while (idx != E[i].end()) {
            Head.push_back(*idx);
            idx++;
          }
          while (idy != E[*it].end()) {
            Tail.push_back(*idy);
            idy++;
          }
        }
        vector<int>::iterator itHead = Head.begin(),
                              itHeadTail = HeadTail.begin(),
                              itTail = Tail.begin();
        while ((itHead != Head.end()) && (H)) {
          cout << *itHead + 1 << " ";
          itHead++;
          H--;
        }
        while (H) {
          cout << *itHeadTail + 1 << " ";
          itHeadTail++;
          H--;
        }
        cout << endl;
        while ((itTail != Tail.end()) && (T)) {
          cout << *itTail + 1 << " ";
          itTail++;
          T--;
        }
        while (T) {
          cout << *itHeadTail + 1 << " ";
          itHeadTail++;
          T--;
        }
        cout << endl;
        return 0;
      }
    }
  cout << "NO" << endl;
  return 0;
}
