#include <bits/stdc++.h>
#pragma comment(linker, "/stack:100000000")
using namespace std;
const int N = 100100;
vector<int> g[N];
int a[2 * N], b[2 * N];
int main() {
  int n, m, h, t;
  scanf("%d %d %d %d", &n, &m, &h, &t);
  for (int(i) = 0; (i) < (m); (i)++) {
    scanf("%d %d", &a[i], &b[i]);
    --a[i], --b[i];
    a[m + i] = b[i];
    b[m + i] = a[i];
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  for (int(i) = 0; (i) < (n); (i)++) sort((g[i]).begin(), (g[i]).end());
  for (int(i) = 0; (i) < (2 * m); (i)++) {
    int u = a[i], v = b[i], j = 0, k = 0;
    vector<int> p, q, c;
    while (j < (int)(g[u]).size() && k < (int)(g[v]).size() &&
           (int)(p).size() < h && (int)(q).size() < t) {
      if (g[u][j] == v) {
        ++j;
        continue;
      }
      if (g[v][k] == u) {
        ++k;
        continue;
      }
      if (g[u][j] == g[v][k]) {
        c.push_back(g[u][j]);
        ++j, ++k;
      } else if (g[u][j] < g[v][k]) {
        p.push_back(g[u][j]);
        ++j;
      } else {
        q.push_back(g[v][k]);
        ++k;
      }
    }
    while (j < (int)(g[u]).size() && (int)(p).size() < h) {
      if (g[u][j] != v) p.push_back(g[u][j]);
      ++j;
    }
    while (k < (int)(g[v]).size() && (int)(q).size() < t) {
      if (g[v][k] != u) q.push_back(g[v][k]);
      ++k;
    }
    j = 0;
    while ((int)(p).size() < h && j < (int)(c).size()) {
      p.push_back(c[j++]);
    }
    while ((int)(q).size() < t && j < (int)(c).size()) {
      q.push_back(c[j++]);
    }
    if ((int)(p).size() == h && (int)(q).size() == t) {
      puts("YES");
      printf("%d %d\n", u + 1, v + 1);
      for (int(id) = 0; (id) < (h); (id)++) printf("%d ", p[id] + 1);
      printf("\n");
      for (int(id) = 0; (id) < (t); (id)++) printf("%d ", q[id] + 1);
      printf("\n");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
