#include <bits/stdc++.h>
using namespace std;
int n, m, h, t, k, i, j, a, b, u, v, len, raod;
vector<int> g[1000000];
int fix[1000000], kix[1000000];
int main() {
  scanf("%d %d %d %d", &n, &m, &h, &t);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (i = 1; i <= n; i++)
    for (j = 0; j < g[i].size(); j++) {
      u = i;
      v = g[i][j];
      if (g[u].size() <= h || g[v].size() <= t) continue;
      raod++;
      for (k = 0; k < g[u].size(); k++) fix[g[u][k]] = raod;
      len = 0;
      for (k = 0; k < g[v].size(); k++)
        if (fix[g[v][k]] == raod) len++;
      if (g[u].size() + g[v].size() - len - 2 >= h + t) {
        cout << "YES" << endl;
        cout << u << " " << v << endl;
        for (k = 0; k < g[u].size(); k++) kix[g[u][k]] = 1;
        for (k = 0; k < g[v].size(); k++)
          if (kix[g[v][k]] == 1) kix[g[v][k]] = 2;
        raod = max(0, (int)(h - (g[u].size() - len - 1)));
        len = 0;
        for (k = 0; k < g[u].size() && len < h; k++)
          if (kix[g[u][k]] == 1 && g[u][k] != v) {
            cout << g[u][k] << " ";
            len++;
          } else if (kix[g[u][k]] == 2 && g[u][k] != v && raod > 0) {
            len++;
            cout << g[u][k] << " ";
            raod--;
            kix[g[u][k]] = 3;
          }
        cout << endl;
        len = 0;
        for (k = 0; k < g[v].size() && len < t; k++)
          if ((kix[g[v][k]] == 0 || kix[g[v][k]] == 2) && (g[v][k] != u)) {
            len++;
            cout << g[v][k] << " ";
          }
        cout << endl;
        return 0;
      }
    }
  cout << "NO" << endl;
}
