#include <bits/stdc++.h>
using namespace std;
int n, m, h, t;
vector<int> adj[100005];
vector<int> second;
vector<pair<int, int> > E;
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    E.push_back(make_pair(u, v));
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) sort(adj[i].begin(), adj[i].end());
  for (int i = 0; i < m; ++i) {
    int u = E[i].first;
    int v = E[i].second;
    second.clear();
    int X = (int)adj[u].size() - 1, Y = (int)adj[v].size() - 1;
    if (!(X >= h && Y >= t || X >= t && Y >= h)) continue;
    for (int j = 0; j < (int)adj[u].size(); ++j) {
      int x = adj[u][j];
      if (binary_search(adj[v].begin(), adj[v].end(), x)) second.push_back(x);
    }
    if (X >= h && Y >= t && X + Y - (int)second.size() >= h + t) {
      printf("YES\n%d %d\n", u, v);
      int c = 0, k = 0;
      for (int j = 0; c < h && j < (int)adj[u].size(); ++j) {
        if (adj[u][j] == v) continue;
        if (binary_search(adj[v].begin(), adj[v].end(), adj[u][j])) continue;
        printf("%d ", adj[u][j]), c++;
      }
      for (; k < (int)second.size() && c < h; ++k)
        printf("%d ", second[k]), c++;
      printf("\n"), c = 0;
      for (int j = 0; c < t && j < (int)adj[v].size(); ++j) {
        if (adj[v][j] == u) continue;
        if (binary_search(adj[u].begin(), adj[u].end(), adj[v][j])) continue;
        printf("%d ", adj[v][j]), c++;
      }
      for (; k < (int)second.size() && c < t; ++k)
        printf("%d ", second[k]), c++;
      return 0;
    }
    X = (int)adj[v].size() - 1, Y = (int)adj[u].size() - 1;
    if (X >= h && Y >= t && X + Y - (int)second.size() >= h + t) {
      printf("YES\n%d %d\n", v, u);
      int c = 0, k = 0;
      for (int j = 0; c < h && j < (int)adj[v].size(); ++j) {
        if (adj[v][j] == u) continue;
        if (binary_search(adj[u].begin(), adj[u].end(), adj[v][j])) continue;
        printf("%d ", adj[v][j]), c++;
      }
      for (; k < (int)second.size() && c < h; ++k)
        printf("%d ", second[k]), c++;
      printf("\n"), c = 0;
      for (int j = 0; c < t && j < (int)adj[u].size(); ++j) {
        if (adj[u][j] == v) continue;
        if (binary_search(adj[v].begin(), adj[v].end(), adj[u][j])) continue;
        printf("%d ", adj[u][j]), c++;
      }
      for (; k < (int)second.size() && c < t; ++k)
        printf("%d ", second[k]), c++;
      return 0;
    }
  }
  printf("NO");
  return 0;
}
