#include <bits/stdc++.h>
using namespace std;
vector<int> g[111111];
bool used[111111];
int main() {
  int n, m, h, t;
  cin >> n >> m >> h >> t;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int hi = 1; hi <= n; hi++) {
    if (g[hi].size() >= h + 1) {
      for (int j = 0; j < g[hi].size(); j++) {
        int ti = g[hi][j];
        if (g[ti].size() >= t + 1) {
          memset(used, 0, sizeof(used));
          int hnum = 0, tnum = 0;
          for (int j = 0; j < g[hi].size(); j++) {
            if (g[hi][j] != ti) {
              hnum++;
              used[g[hi][j]] = 1;
            }
          }
          for (int j = 0; j < g[ti].size(); j++) {
            if (g[ti][j] != hi) {
              if (!used[g[ti][j]])
                tnum++;
              else if (hnum > h) {
                used[g[ti][j]] = false, tnum++, hnum--;
              }
            }
          }
          if (hnum < h || tnum < t) continue;
          puts("YES");
          printf("%d %d\n", hi, ti);
          for (int i = 0; i < g[hi].size() && h; i++)
            if (used[g[hi][i]]) {
              printf("%d ", g[hi][i]);
              h--;
            }
          puts("");
          for (int i = 0; i < g[ti].size() && t; i++)
            if (!used[g[ti][i]] && g[ti][i] != hi) {
              printf("%d ", g[ti][i]);
              t--;
            }
          return 0;
        }
      }
    }
  }
  cout << "NO";
  return 0;
}
