#include <bits/stdc++.h>
using namespace std;
const int M = 100000 + 10;
struct EDGE {
  int u;
  int v;
} edge[M];
vector<EDGE> adj[M];
int n, m, h, t;
vector<int> resh;
vector<int> rest;
int flag[M];
void solve(int u, int v) {
  int udeg = adj[u].size() - 1;
  int vdeg = adj[v].size() - 1;
  if (udeg < h || vdeg < t) {
    return;
  } else {
    if (udeg >= h + t || vdeg >= h + t) {
      if (udeg >= h + t) {
        for (int i = 0; i < adj[v].size(); i++) {
          EDGE edge = adj[v][i];
          int eu = edge.u;
          int ev = edge.v;
          int nxt = eu == v ? ev : eu;
          if (nxt != u) {
            rest.push_back(nxt);
            flag[nxt] = 1;
            if (rest.size() == t) {
              break;
            }
          }
        }
        for (int i = 0; i < adj[u].size(); i++) {
          EDGE edge = adj[u][i];
          int eu = edge.u;
          int ev = edge.v;
          int nxt = eu == u ? ev : eu;
          if (nxt != v && flag[nxt] == 0) {
            resh.push_back(nxt);
            if (resh.size() == h) {
              break;
            }
          }
        }
      } else {
        if (vdeg >= h + t) {
          for (int i = 0; i < adj[u].size(); i++) {
            EDGE edge = adj[u][i];
            int eu = edge.u;
            int ev = edge.v;
            int nxt = eu == u ? ev : eu;
            if (nxt != v) {
              resh.push_back(nxt);
              flag[nxt] = 1;
              if (resh.size() == h) {
                break;
              }
            }
          }
          for (int i = 0; i < adj[v].size(); i++) {
            EDGE edge = adj[v][i];
            int eu = edge.u;
            int ev = edge.v;
            int nxt = eu == v ? ev : eu;
            if (nxt != u && flag[nxt] == 0) {
              rest.push_back(nxt);
              if (rest.size() == t) {
                break;
              }
            }
          }
        }
      }
    } else {
      for (int i = 0; i < adj[u].size(); i++) {
        EDGE edge = adj[u][i];
        int eu = edge.u;
        int ev = edge.v;
        int nxt = eu == u ? ev : eu;
        if (nxt != v) {
          flag[nxt] = 1;
        }
      }
      int tmp[300];
      int num = 0;
      for (int i = 0; i < adj[v].size(); i++) {
        EDGE edge = adj[v][i];
        int eu = edge.u;
        int ev = edge.v;
        int nxt = eu == v ? ev : eu;
        if (nxt != u) {
          if (flag[nxt] == 0) {
            rest.push_back(nxt);
          } else {
            if (flag[nxt] == 1) {
              flag[nxt] = 2;
              tmp[num++] = nxt;
            }
          }
        }
      }
      while (rest.size() < t) {
        int val = tmp[num - 1];
        rest.push_back(val);
        flag[val] = 0;
        num--;
      }
      for (int i = 0; i < adj[u].size(); i++) {
        EDGE edge = adj[u][i];
        int eu = edge.u;
        int ev = edge.v;
        int nxt = -1;
        if (eu == u) {
          nxt = ev;
        } else {
          nxt = eu;
        }
        if (flag[nxt] != 0) {
          resh.push_back(nxt);
        }
        flag[nxt] = 0;
      }
    }
  }
}
int main() {
  cin >> n >> m >> h >> t;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    edge[i].u = u;
    edge[i].v = v;
    adj[u].push_back(edge[i]);
    adj[v].push_back(edge[i]);
  }
  bool ok = false;
  for (int i = 0; i < m; i++) {
    int u = edge[i].u;
    int v = edge[i].v;
    solve(u, v);
    if (resh.size() >= h && rest.size() >= t) {
      cout << "YES" << endl;
      cout << u << " " << v << endl;
      for (int j = 0; j < h; j++) {
        cout << resh[j] << " ";
      }
      cout << endl;
      for (int j = 0; j < t; j++) {
        cout << rest[j] << " ";
      }
      ok = true;
      break;
    } else {
      resh.clear();
      rest.clear();
    }
    solve(v, u);
    if (resh.size() >= h && rest.size() >= t) {
      cout << "YES" << endl;
      cout << v << " " << u << endl;
      for (int j = 0; j < h; j++) {
        cout << resh[j] << " ";
      }
      cout << endl;
      for (int j = 0; j < t; j++) {
        cout << rest[j] << " ";
      }
      ok = true;
      break;
    } else {
      resh.clear();
      rest.clear();
    }
  }
  if (ok == false) {
    cout << "NO" << endl;
  }
  return 0;
}
