#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, h, t;
vector<int> e[N];
int flag[N], cnt;
void init() {
  scanf("%d %d %d %d", &n, &m, &h, &t);
  for (int i = 0, x, y; i < m; ++i) {
    scanf("%d %d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
}
void get(int u, int v) {
  vector<int> p;
  int s = h + t;
  for (int i = 0; i < e[u].size() && s; ++i, --s)
    if (e[u][i] != v) {
      p.push_back(e[u][i]);
      flag[e[u][i]] = cnt;
    }
  s = h + t;
  for (int i = 0; i < e[v].size() && s; ++i, --s)
    if (e[v][i] != u) {
      if (flag[e[v][i]] == cnt) {
        flag[e[v][i]] = -cnt;
        continue;
      }
      p.push_back(e[v][i]);
    }
  if (p.size() < h + t) return;
  vector<int> su, sv, common;
  for (int i = 0; i < p.size(); ++i) {
    if (flag[p[i]] == cnt)
      su.push_back(p[i]);
    else if (flag[p[i]] == -cnt)
      common.push_back(p[i]);
    else
      sv.push_back(p[i]);
  }
  while (su.size() < h && common.size()) {
    su.push_back(common.back());
    common.pop_back();
  }
  while (sv.size() < t && common.size()) {
    sv.push_back(common.back());
    common.pop_back();
  }
  if (su.size() < h || sv.size() < t) return;
  puts("YES");
  printf("%d %d\n", u, v);
  for (int i = 0; i < h; ++i) cout << su[i] << ' ';
  cout << endl;
  for (int i = 0; i < t; ++i) cout << sv[i] << ' ';
  cout << endl;
  exit(0);
}
void solve() {
  memset(flag, 0, sizeof(flag));
  cnt = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < e[i].size(); ++j) cnt += 1, get(i, e[i][j]);
  puts("NO");
}
int main() {
  init();
  solve();
  return 0;
}
