#include <bits/stdc++.h>
using namespace std;
int flag[100010], n, m, h, t, pr, f, x, y;
vector<int> adj[100010];
void IsHydra(int a, int b) {
  int h1 = 0, t1 = 0, c1 = 0, c2 = 0;
  f++;
  for (int i = 0; i < adj[a].size(); i++) {
    flag[adj[a][i]] = f;
    if (adj[a][i] != b) h1++;
  }
  for (int i = 0; i < adj[b].size(); i++) {
    if (adj[b][i] != a && flag[adj[b][i]] != f) t1++;
    if (h1 > h && flag[adj[b][i]] == f) t1++, h1--, flag[adj[b][i]] = f - 1;
  }
  if (h1 >= h && t1 >= t) {
    pr = 1;
    printf("YES\n");
    printf("%d %d\n", a, b);
    for (int i = 0; i < adj[a].size(); i++) {
      if (flag[adj[a][i]] == f && c1 < h && adj[a][i] != b) {
        c1++;
        printf("%d ", adj[a][i]);
      }
    }
    printf("\n");
    for (int i = 0; i < adj[b].size(); i++) {
      if (flag[adj[b][i]] != f && c2 < t && adj[b][i] != a) {
        c2++;
        printf("%d ", adj[b][i]);
      }
    }
  }
}
int main() {
  scanf("%d %d %d %d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() <= h) continue;
    for (int j = 0; j < adj[i].size(); j++) {
      if (pr == 1) return 0;
      if (adj[adj[i][j]].size() <= t) continue;
      IsHydra(i, adj[i][j]);
    }
  }
  if (pr == 1) return 0;
  printf("NO");
  return 0;
}
