#include <bits/stdc++.h>
using namespace std;
vector<int> graph[150000];
vector<int> vet;
map<int, bool> bullet[150000];
bool usado[150000];
int main() {
  int n, m, h, t, a, b;
  scanf(" %d %d %d %d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++) {
    scanf(" %d %d", &a, &b);
    graph[a].push_back(b);
    graph[b].push_back(a);
    bullet[a][b] = true;
    bullet[b][a] = true;
  }
  for (int i = 1; i <= n; i++)
    if (graph[i].size() - 1 >= h) vet.push_back(i);
  for (int i = 0; i < vet.size(); i++) {
    int u = vet[i];
    int sum = graph[u].size() - 1;
    for (int j = 0; j < graph[u].size(); j++) {
      int v = graph[u][j];
      if (graph[v].size() - 1 < t) continue;
      int total = sum;
      for (int k = 0; k < graph[v].size(); k++)
        if (graph[v][k] != u && !bullet[u][graph[v][k]]) total++;
      if (total >= h + t) {
        int used = 0;
        printf("YES\n");
        printf("%d %d\n", u, v);
        for (int i = 0; i < graph[u].size() && used < h; i++)
          if (graph[u][i] != v && !bullet[v][graph[u][i]]) {
            usado[graph[u][i]] = true;
            printf("%d ", graph[u][i]);
            used++;
          }
        for (int i = 0; i < graph[u].size() && used < h; i++)
          if (graph[u][i] != v && !usado[graph[u][i]]) {
            usado[graph[u][i]] = true;
            printf("%d ", graph[u][i]);
            used++;
          }
        printf("\n");
        for (int i = 0; i < graph[v].size() && t; i++)
          if (graph[v][i] != u && !usado[graph[v][i]]) {
            printf("%d ", graph[v][i]);
            t--;
          }
        printf("\n");
        return 0;
      }
    }
  }
  printf("NO\n");
  return 0;
}
