#include <bits/stdc++.h>
struct Edge {
  int u, v;
  Edge(int u_ = 0, int v_ = 0) : u(std::min(u_, v_)), v(std::max(u_, v_)) {}
};
bool operator<(const Edge &a, const Edge &b) {
  return a.u < b.u || (a.u == b.u && a.v < b.v);
}
const int NMAX = (int)1e5;
namespace Used {
int data[1 + NMAX];
};
bool difference(std::vector<std::vector<int> > &next, int &u, int &v, int nH,
                int nT, std::vector<int> &fi, std::vector<int> &se,
                std::vector<int> &same) {
  if (next[u].size() > next[v].size()) {
    return difference(next, v, u, nT, nH, se, fi, same);
  }
  fi.clear();
  se.clear();
  same.clear();
  auto &vec_u = next[u];
  auto &vec_v = next[v];
  for (auto vert : vec_u) {
    if (vert == v || vert == u) {
      continue;
    }
    if (std::binary_search((vec_v).begin(), (vec_v).end(), vert)) {
      same.push_back(vert);
    } else {
      fi.push_back(vert);
    }
  }
  if ((int)(fi.size() + same.size()) < nH) {
    return false;
  }
  for (auto &it : fi) {
    Used::data[it] = 1;
  }
  for (auto &it : same) {
    Used::data[it] = 3;
  }
  for (auto vert : vec_v) {
    if (vert == u || vert == v) {
      continue;
    }
    if (Used::data[vert] == 0) {
      se.push_back(vert);
    }
    if ((int)(fi.size() + se.size() + same.size()) >= nH + nT &&
        (int)(fi.size() + same.size()) >= nH &&
        (int)(se.size() + same.size()) >= nT) {
      break;
    }
  }
  bool ok = ((int)(fi.size() + se.size() + same.size()) >= nH + nT &&
             (int)(fi.size() + same.size()) >= nH &&
             (int)(se.size() + same.size()) >= nT);
  for (auto &it : fi) {
    Used::data[it] = 0;
  }
  for (auto &it : same) {
    Used::data[it] = 0;
  }
  if (!ok) {
    return false;
  }
  while (!same.empty()) {
    if ((int)fi.size() < nH) {
      fi.push_back(same.back());
    } else {
      se.push_back(same.back());
    }
    same.pop_back();
  }
  return ok;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  std::cerr.tie(0);
  int nV, nE, nH, nT;
  while (std::cin >> nV >> nE >> nH >> nT) {
    std::vector<Edge> edges;
    for (int i = 0, u, v; i < nE; ++i) {
      std::cin >> u >> v;
      edges.push_back(Edge(u, v));
    }
    std::sort((edges).begin(), (edges).end());
    std::vector<std::vector<int> > next(1 + nV);
    for (auto &e : edges) {
      next[e.u].push_back(e.v);
      next[e.v].push_back(e.u);
    }
    for (int u = 1; u <= nV; ++u) {
      std::sort((next[u]).begin(), (next[u]).end());
    }
    std::vector<int> fi, se, same;
    int u = 6, v = 7;
    bool ok = false;
    if (!ok) {
      for (auto &e : edges) {
        fi.clear();
        se.clear();
        u = e.u, v = e.v;
        if (difference(next, u, v, nH, nT, fi, se, same)) {
          ok = true;
          break;
        }
      }
    }
    if (!ok) {
      for (auto &e : edges) {
        std::swap(e.u, e.v);
      }
      std::sort((edges).begin(), (edges).end());
      for (auto &e : edges) {
        fi.clear();
        se.clear();
        u = e.u, v = e.v;
        if (difference(next, u, v, nH, nT, fi, se, same)) {
          ok = true;
          break;
        }
      }
    }
    if (ok) {
      std::cout << "YES\n";
      std::cout << u << ' ' << v << "\n";
      assert((int)fi.size() >= nH);
      fi.resize(nH);
      for (auto &it : fi) {
        std::cout << it << ' ';
      }
      std::cout << "\n";
      assert((int)se.size() >= nT);
      se.resize(nT);
      for (auto &it : se) {
        std::cout << it << ' ';
      }
      std::cout << "\n";
    } else {
      std::cout << "NO\n";
    }
  }
  return 0;
}
