#include <bits/stdc++.h>
using namespace std;
const int MX = 4e5 + 100;
int N, M;
struct Graph {
  int y, nx;
  char t;
} E[MX];
int H[MX], ec;
void add(int x, int y) { E[++ec].y = y, E[ec].nx = H[x], H[x] = ec; }
struct Edge {
  int x, y;
} Ed[MX];
int cnt;
int P[MX], pc;
char B[MX];
void dfs1(int x, int f) {
  P[++pc] = x, B[x] = 1;
  for (int i = H[x]; i; i = E[i].nx)
    if (E[i].y != f) {
      if (B[E[i].y] == 1)
        Ed[++cnt].x = x, Ed[cnt].y = E[i].y;
      else if (B[E[i].y] == 0)
        E[i].t = 1, dfs1(E[i].y, x);
    }
  B[x] = 2;
}
int D[MX], F[MX], sz[MX], son[MX], U[MX];
void dfs2(int x, int f, int d) {
  D[x] = d, F[x] = f, sz[x] = 1, son[x] = -1;
  int mx = 0;
  for (int i = H[x]; i; i = E[i].nx)
    if (E[i].t) {
      dfs2(E[i].y, x, d + 1), sz[x] += sz[E[i].y];
      if (sz[E[i].y] > mx) mx = sz[E[i].y], son[x] = E[i].y;
    }
}
void dfs3(int x, int u) {
  U[x] = u;
  if (son[x] != -1) dfs3(son[x], u);
  for (int i = H[x]; i; i = E[i].nx)
    if (E[i].t && E[i].y != son[x]) dfs3(E[i].y, E[i].y);
}
int Lca(int x, int y) {
  while (U[x] != U[y]) {
    if (D[U[x]] > D[U[y]])
      x = F[U[x]];
    else
      y = F[U[y]];
  }
  if (D[x] < D[y])
    return x;
  else
    return y;
}
int C[MX];
void dfs4(int x) {
  for (int i = H[x]; i; i = E[i].nx)
    if (E[i].t) dfs4(E[i].y), C[x] += C[E[i].y];
}
int stk[MX];
void solve(int x) {
  cnt = 0, pc = 0;
  dfs1(x, 0);
  dfs2(x, 0, 1);
  dfs3(x, x);
  for (int i = (1); i <= (cnt); ++i) {
    int x = Ed[i].x, y = Ed[i].y;
    C[x]++, C[y]--;
  }
  dfs4(x);
  int mx = -1, a = -1, b = -1, c = -1, d = -1, e = -1, f = -1;
  for (int j = (1); j <= (pc); ++j) {
    int i = P[j];
    if (C[i] >= 2 && D[i] > mx) mx = D[i], a = i;
  }
  if (a == -1) return;
  printf("YES\n");
  for (int i = (1); i <= (cnt); ++i) {
    int x = Ed[i].x, y = Ed[i].y;
    if (Lca(x, a) == a && D[y] < D[a]) {
      if (b == -1) {
        b = x, d = y;
        continue;
      }
      if (c == -1) {
        c = x, e = y;
        continue;
      }
    }
    if (b != -1 && c != -1) break;
  }
  f = D[d] > D[e] ? d : e;
  int stktop = 0, now = a;
  stk[++stktop] = now;
  while (now != f) now = F[now], stk[++stktop] = now;
  printf("%d ", stktop);
  for (int i = (1); i <= (stktop); ++i) printf("%d ", stk[i]);
  printf("\n");
  stktop = 0, now = f;
  stk[++stktop] = now;
  while (now != a) {
    if (now == d)
      now = b;
    else
      now = F[now];
    stk[++stktop] = now;
  }
  printf("%d ", stktop);
  for (int i = (stktop); i >= (1); --i) printf("%d ", stk[i]);
  printf("\n");
  stktop = 0, now = f;
  stk[++stktop] = now;
  while (now != a) {
    if (now == e)
      now = c;
    else
      now = F[now];
    stk[++stktop] = now;
  }
  printf("%d ", stktop);
  for (int i = (stktop); i >= (1); --i) printf("%d ", stk[i]);
  printf("\n");
  exit(0);
}
int main() {
  scanf("%d%d", &N, &M);
  int x, y;
  for (int i = (1); i <= (M); ++i) scanf("%d%d", &x, &y), add(x, y), add(y, x);
  for (int i = (1); i <= (N); ++i)
    if (!B[i]) solve(i);
  printf("NO\n");
  return 0;
}
