#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, h, t, uu, vv;
  int flag[100017];
  vector<int> v[100017], an;
  while (~scanf("%d%d%d%d", &n, &m, &h, &t)) {
    memset(flag, 0, sizeof(flag));
    an.clear();
    for (int i = 1; i <= n; i++) v[i].clear();
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &uu, &vv);
      v[uu].push_back(vv);
      v[vv].push_back(uu);
    }
    for (int i = 1; i <= n; i++) {
      int le = v[i].size();
      if (le >= (h + 1) || le >= (t + 1)) {
        an.push_back(i);
      }
    }
    int te, len, te2;
    int l = an.size();
    int fg = 0, a, b, tt, ttt1, ttt2, ll, rr, mid;
    int fff[100017];
    memset(fff, 0, sizeof(fff));
    for (int i = 0; i <= l - 1; i++) {
      memset(flag, 0, sizeof(flag));
      te = an[i];
      fff[te] = 1;
      len = v[te].size();
      for (int ii = 0; ii <= len - 1; ii++) flag[v[te][ii]]++;
      for (int j = 0; j <= len - 1; j++) {
        te2 = v[te][j];
        if (fff[te2] == 1) continue;
        int len2 = v[te2].size();
        if (len >= h + 1 && len2 >= t + 1) {
          ttt1 = len + len2 - 2;
          ttt2 = 0;
          for (int ii = 0; ii <= len2 - 1; ii++) {
            if (flag[v[te2][ii]] == 1) ttt2++;
          }
          if ((ttt1 - ttt2) >= t + h) {
            a = te;
            b = te2;
            fg = 1;
            break;
          }
        } else if (len >= t + 1 && len2 >= h + 1) {
          ttt1 = len + len2 - 2;
          ttt2 = 0;
          for (int ii = 0; ii <= len2 - 1; ii++) {
            if (flag[v[te2][ii]] == 1) ttt2++;
          }
          if ((ttt1 - ttt2) >= h + t) {
            a = te2;
            b = te;
            fg = 1;
            break;
          }
        }
      }
      if (fg == 1) break;
    }
    if (fg == 0)
      printf("NO\n");
    else {
      int flag2[100017];
      memset(flag2, 0, sizeof(flag2));
      len = v[a].size();
      int len2 = v[b].size();
      for (int ii = 0; ii <= len - 1; ii++) flag2[v[a][ii]]++;
      for (int ii = 0; ii <= len2 - 1; ii++) flag2[v[b][ii]]++;
      memset(flag, 0, sizeof(flag));
      int cnt = 0;
      printf("YES\n%d %d\n", a, b);
      for (int i = 0; i <= len - 1; i++) {
        if (v[a][i] == b)
          continue;
        else if (flag2[v[a][i]] == 1) {
          printf("%d ", v[a][i]);
          cnt++;
          flag[v[a][i]]++;
        }
        if (cnt == h) break;
      }
      if (cnt < h) {
        for (int i = 0; i <= len - 1; i++) {
          if (v[a][i] == b)
            continue;
          else if (flag2[v[a][i]] == 2) {
            printf("%d ", v[a][i]);
            cnt++;
            flag[v[a][i]]++;
          }
          if (cnt == h) break;
        }
      }
      printf("\n");
      cnt = 0;
      for (int i = 0; i <= len2 - 1; i++) {
        if (v[b][i] == a) continue;
        if (flag[v[b][i]] != 0) continue;
        printf("%d ", v[b][i]);
        cnt++;
        if (cnt == t) break;
      }
      printf("\n");
    }
  }
  return 0;
}
