#include <bits/stdc++.h>
using namespace std;
int n, m, h, t, u, v, tim, d[100100], w[100100], W[100100];
vector<int> e[100100], ans;
int main() {
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (int i = 0; i < m; i++)
    scanf("%d%d", &u, &v), e[u].push_back(v), e[v].push_back(u);
  for (int i = 1; i < n + 1; i++) d[i] = e[i].size();
  for (int i = 1; i < n + 1; i++) {
    if (d[i] <= h) continue;
    for (int j : e[i]) w[j] = i;
    for (int j : e[i]) {
      tim++;
      int p = d[i] - 1 - h, q = 0;
      ans.clear();
      for (int k : e[j]) {
        if (k != i)
          if (p && w[k] == i)
            p--, q++, ans.push_back(k), W[k] = tim;
          else if (w[k] != i)
            q++, ans.push_back(k), W[k] = tim;
        if (q == t) break;
      }
      if (q == t) {
        puts("YES");
        printf("%d %d\n", i, j);
        int p = 0;
        for (int k : e[i])
          if (k != j && W[k] != tim) {
            p++, printf("%d ", k);
            if (p == h) break;
          }
        puts("");
        for (int k : ans) printf("%d ", k);
        return 0;
      }
    }
  }
  puts("NO");
}
