#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> nodes[N], common;
vector<pair<int, int> > edges;
int degree[N], n, m, h, t, old;
bool vis[N];
int check(int x, int y) {
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < nodes[x].size(); ++i) {
    vis[nodes[x][i]] = true;
  }
  common.clear();
  for (int i = 0; i < nodes[y].size(); ++i) {
    if (vis[nodes[y][i]]) {
      vis[nodes[y][i]] = false;
      common.push_back(nodes[y][i]);
    }
  }
  return common.size();
}
void Print(int x, int y) {
  printf("YES\n%d %d\n", x, y);
  int a = 0, b = 0;
  for (int i = 0; i < nodes[x].size() && a < h; ++i) {
    if (nodes[x][i] == y) continue;
    if (vis[nodes[x][i]]) {
      printf("%d ", nodes[x][i]);
      ++a;
    }
  }
  for (int i = 0; i < common.size() && a < h; ++i) {
    vis[common[i]] = true;
    printf("%d ", common[i]);
    ++a;
  }
  printf("\n");
  for (int i = 0; i < nodes[y].size() && b < t; ++i) {
    if (vis[nodes[y][i]] || nodes[y][i] == x) continue;
    printf("%d ", nodes[y][i]);
    ++b;
  }
  printf("\n");
}
int main(void) {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  int x, y;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &x, &y);
    nodes[x].push_back(y);
    ++degree[x];
    nodes[y].push_back(x);
    ++degree[y];
    edges.push_back(make_pair(x, y));
  }
  sort(edges.begin(), edges.end(), greater<pair<int, int> >());
  for (int i = 0; i < m; ++i) {
    x = edges[i].first;
    y = edges[i].second;
    if (degree[x] >= h + 1 && degree[y] >= t + 1) {
      int k = check(x, y);
      if (degree[x] + degree[y] - k >= h + t + 2) {
        Print(x, y);
        return 0;
      }
    } else if (degree[y] >= h + 1 && degree[x] >= t + 1) {
      int k = check(y, x);
      if (degree[x] + degree[y] - k >= h + t + 2) {
        Print(y, x);
        return 0;
      }
    }
  }
  printf("NO\n");
  return 0;
}
