#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 1e5 + 5, inf = 0x3f3f3f3f;
vector<int> e[maxn], ans;
int n, m, t, h, k, tim, du[maxn], cnt, c[maxn], vis[maxn];
int main() {
  cin >> n >> m >> h >> t;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
    du[u]++, du[v]++;
  }
  for (int i = 1; i <= m; i++) {
    if (du[i] <= h) continue;
    for (auto j : e[i]) c[j] = i;
    for (auto j : e[i]) {
      tim++;
      int p = du[i] - 1 - h, q = 0;
      ans.clear();
      for (auto k : e[j]) {
        if (k != i) {
          if (c[k] == i && p) {
            p--;
            q++;
            vis[k] = tim;
            ans.push_back(k);
          } else if (c[k] != i) {
            q++;
            vis[k] = tim;
            ans.push_back(k);
          }
        }
        if (q == t) break;
      }
      if (q == t) {
        int res = 0;
        puts("YES");
        printf("%d %d\n", i, j);
        for (int k : e[i]) {
          if (k != j && vis[k] != tim) {
            printf("%d ", k);
            res++;
          }
          if (res == h) break;
        }
        puts("");
        for (auto x : ans) {
          printf("%d ", x);
        }
        return 0;
      }
    }
  }
  puts("NO");
}
