#include <bits/stdc++.h>
int main() {
  std::vector<std::pair<int, int> > g;
  int n, m, x, y, h, t;
  std::scanf("%d%d%d%d", &n, &m, &h, &t);
  std::vector<std::vector<int> > to(n, std::vector<int>(0));
  for (int i = 0; i < m; i++) {
    std::scanf("%d%d", &x, &y);
    x--;
    y--;
    to[x].push_back(y);
    to[y].push_back(x);
    g.push_back(std::make_pair(x, y));
    g.push_back(std::make_pair(y, x));
  }
  std::vector<int> used(n, 0);
  for (std::pair<int, int> ht : g) {
    if ((to[ht.first].size() <= h) || (to[ht.second].size() <= t)) continue;
    std::vector<int> head, tail, all;
    for (int nv : to[ht.first]) {
      if (nv == ht.second) continue;
      used[nv] = 1;
    }
    for (int nv : to[ht.second]) {
      if (nv == ht.first) continue;
      used[nv] += 2;
      if (used[nv] == 3)
        all.push_back(nv);
      else
        tail.push_back(nv);
      used[nv] = 0;
    }
    for (int nv : to[ht.first]) {
      if (used[nv] == 1) head.push_back(nv);
      used[nv] = 0;
    }
    while (head.size() < h && !all.empty()) {
      head.push_back(all.back());
      all.pop_back();
    }
    while (tail.size() < t && !all.empty()) {
      tail.push_back(all.back());
      all.pop_back();
    }
    if ((head.size() < h) || (tail.size() < t)) continue;
    std::printf("YES\n%d %d\n", ht.first + 1, ht.second + 1);
    for (int i = 0; i < h; i++) std::printf("%d ", head[i] + 1);
    std::printf("\n");
    for (int i = 0; i < t; i++) std::printf("%d ", tail[i] + 1);
    return 0;
  }
  std::printf("NO");
}
