#include <bits/stdc++.h>
using namespace std;
int n, m, h, du[200000], sz[1000000], ans[3][1000000], bian[1000000][3], t,
    tou[1000000], hj[1000000], e;
void out(int i, int j) {
  cout << "YES" << endl;
  cout << i << " " << j << endl;
  for (i = 1; i <= h; i++) cout << ans[1][i] << " ";
  cout << endl;
  for (i = 1; i <= t; i++) cout << ans[2][i] << " ";
  cout << endl;
  exit(0);
}
void run(int i, int j, int cun) {
  int now;
  now = tou[i];
  while (now != 0) {
    if (bian[now][1] != j) {
      ans[cun][0]++;
      ans[cun][ans[cun][0]] = bian[now][1];
      sz[bian[now][1]] = 1;
      if (ans[cun][0] == max(h, t)) break;
    }
    now = hj[now];
  }
  now = tou[j];
  int tmp;
  if (cun == 1)
    tmp = 2;
  else
    tmp = 1;
  while (now != 0) {
    if (bian[now][1] != i && sz[bian[now][1]] == 0) {
      ans[tmp][0]++;
      ans[tmp][ans[tmp][0]] = bian[now][1];
      if (ans[tmp][0] == max(h, t)) break;
    }
    now = hj[now];
  }
}
void check(int i, int j) {
  if (du[j] > 220) {
    run(i, j, 1);
    out(i, j);
  } else if (du[i] > 220) {
    run(j, i, 2);
    out(i, j);
  } else {
    int now = tou[i];
    while (now != 0) {
      if (bian[now][1] != j) sz[bian[now][1]]++;
      now = hj[now];
    }
    now = tou[j];
    while (now != 0) {
      if (bian[now][1] != i) sz[bian[now][1]]++;
      now = hj[now];
    }
    ans[1][0] = 0;
    ans[2][0] = 0;
    now = tou[i];
    while (now != 0) {
      if (bian[now][1] != j)
        if (sz[bian[now][1]] == 1) {
          ans[1][0]++;
          ans[1][ans[1][0]] = bian[now][1];
        }
      now = hj[now];
    }
    if (ans[1][0] < h) {
      now = tou[i];
      while (now != 0) {
        if (bian[now][1] != j)
          if (sz[bian[now][1]] == 2) {
            ans[1][0]++;
            ans[1][ans[1][0]] = bian[now][1];
            sz[bian[now][1]] = 0;
            if (ans[1][0] == h) break;
          }
        now = hj[now];
      }
    }
    now = tou[j];
    while (now != 0) {
      if (bian[now][1] != i)
        if (sz[bian[now][1]] == 1) {
          ans[2][0]++;
          ans[2][ans[2][0]] = bian[now][1];
        }
      now = hj[now];
    }
    if (ans[2][0] < t) {
      now = tou[j];
      while (now != 0) {
        if (bian[now][1] != i)
          if (sz[bian[now][1]] == 2) {
            ans[2][0]++;
            ans[2][ans[2][0]] = bian[now][1];
            sz[bian[now][1]] = 0;
          }
        now = hj[now];
      }
    }
    if (ans[1][0] >= h && ans[2][0] >= t) out(i, j);
    now = tou[i];
    while (now != 0) {
      sz[bian[now][1]] = 0;
      now = hj[now];
    }
    now = tou[j];
    while (now != 0) {
      sz[bian[now][1]] = 0;
      now = hj[now];
    }
  }
}
void insert(int i, int j) {
  du[i]++;
  e++;
  bian[e][2] = i;
  bian[e][1] = j;
  hj[e] = tou[i];
  tou[i] = e;
}
int main() {
  int i, tmp1, tmp2;
  scanf("%d%d%d%d", &n, &m, &h, &t);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &tmp1, &tmp2);
    insert(tmp1, tmp2);
    insert(tmp2, tmp1);
  }
  for (i = 1; i <= 2 * m; i++) {
    int a = bian[i][1], b = bian[i][2];
    if (du[a] >= h + 1 && du[b] >= t + 1) check(a, b);
  }
  cout << "NO";
  return 0;
}
