#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
inline bool REMIN(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool REMAX(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
string tostring(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
int bit(long long x, int pos) { return ((1ll << pos) & x) ? 1 : 0; }
const int INF = 1e9;
const int NMAX = 1e5 + 5;
const long long MOD = 1000000007;
const long double PI = 2 * acos(0);
long long power(long long base, long long exp, long long c = MOD) {
  if (!exp) return 1;
  long long r = power(base, exp / 2, c);
  r = (r * r) % c;
  if (exp & 1) r = (r * base) % c;
  return r;
}
int T, N, M, H;
int a, b, c;
string s1, s2;
void nope(int dec = 0) {
  if (!dec) cout << "NO";
  exit(0);
}
vector<int> eds[NMAX];
vector<pair<int, int> > ecs;
int used[NMAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> H >> T;
  for (int(i) = int(1); (i) <= int(M); ++(i)) {
    cin >> a >> b;
    eds[a].push_back(b);
    eds[b].push_back(a);
    ecs.push_back({a, b});
    ecs.push_back({b, a});
  }
  for (auto pa : ecs) {
    int u = pa.first, v = pa.second;
    if (((int)(eds[u].size())) <= H || ((int)(eds[v].size())) <= T) continue;
    vector<int> comm, v1, v2;
    int flag = 0;
    for (int x : eds[u]) used[x] = 1;
    for (int x : eds[v])
      if (used[x]) {
        comm.push_back(x);
        used[x] = 2;
      } else
        v2.push_back(x);
    for (int x : eds[u])
      if (used[x] == 1) v1.push_back(x);
    for (int x : eds[u]) used[x] = 0;
    int bank = ((int)(comm.size()));
    int bor = max(0, H - (((int)(eds[u].size())) - 1 - bank));
    int need = max(0, T - (((int)(eds[v].size())) - 1 - bank));
    if (need + bor > bank) continue;
    if (1) {
      cout << "YES\n";
      int h, t;
      h = u, t = v;
      cout << h << ' ' << t << '\n';
      for (auto ver : v1)
        if (H)
          if (ver != t) {
            cout << ver << ' ';
            H--;
          }
      while (bor--) {
        cout << comm.back() << ' ';
        comm.pop_back();
      }
      cout << '\n';
      for (auto ver : v2)
        if (T)
          if (ver != h) {
            cout << ver << ' ';
            T--;
          }
      while (need--) {
        cout << comm.back() << ' ';
        comm.pop_back();
      }
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
