#include <bits/stdc++.h>
using namespace std;
int n, m, h, t;
vector<vector<int> > g;
vector<pair<int, int> > edges;
bool Find(int x, int y) {
  int l = 0;
  int r = (int)g[y].size() - 1;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (g[y][m] > x) {
      r = m;
    } else {
      l = m;
    }
  }
  if (g[y][l] == x || g[y][r] == x) {
    return true;
  }
  return false;
}
void Print(int x, int y) {
  cout << "YES" << endl;
  if (g[x].size() > g[y].size()) {
    swap(x, y);
  }
  set<int> common;
  for (int i = 0; i < (int)g[x].size(); i++) {
    if (Find(g[x][i], y)) {
      common.insert(g[x][i]);
    }
  }
  if (h > t) {
    swap(x, y);
  }
  cout << x + 1 << " " << y + 1 << endl;
  int xcount = 0, ycount = 0;
  for (int i = 0; i < g[x].size(); i++) {
    int cur = g[x][i];
    if (xcount < h && common.find(cur) == common.end() && cur != y) {
      cout << cur + 1 << " ";
      xcount++;
    }
  }
  set<int> toErase;
  if (xcount != h) {
    for (auto it = common.begin(); it != common.end(); it++) {
      if (xcount == h) break;
      cout << *it + 1 << " ";
      xcount++;
      toErase.insert(*it);
    }
  }
  cout << endl;
  for (int i = 0; i < g[y].size(); i++) {
    int cur = g[y][i];
    if (ycount < t && common.find(cur) == common.end() && cur != x) {
      ycount++;
      cout << cur + 1 << " ";
    }
  }
  for (auto it = toErase.begin(); it != toErase.end(); it++) {
    common.erase(*it);
  }
  if (ycount < t) {
    for (auto it = common.begin(); it != common.end(); it++) {
      if (ycount == t) break;
      cout << *it + 1 << " ";
      ycount++;
    }
  }
}
bool check(int &x, int &y) {
  if (g[x].size() > g[y].size()) {
    swap(x, y);
  }
  vector<int> common;
  for (int i = 0; i < (int)g[x].size(); i++) {
    if (Find(g[x][i], y)) {
      common.push_back(g[x][i]);
    }
  }
  if ((g[x].size() + g[y].size() - 2 - common.size() >= h + t) &&
      ((int)g[x].size() - 1 >= min(h, t)) &&
      ((int)g[y].size() - 1 >= max(h, t))) {
    return true;
  }
  return false;
}
int main(int argc, const char *argv[]) {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  g.resize(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
    edges.push_back(make_pair(x, y));
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
  }
  for (int i = 0; i < m; i++) {
    int x = edges[i].first;
    int y = edges[i].second;
    if (x > y) {
      swap(x, y);
    }
    if (g[x].size() >= 210 && g[y].size() >= 210) {
      Print(x, y);
      return 0;
    } else {
      if (check(x, y)) {
        Print(x, y);
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}
