#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct node {
  int to, nex;
} e[N << 1];
int head[N], f[N], size[N], d[N], s, l1, r1, l2, r2, n, m, a, b, t, cnt;
void add(int x, int y) {
  e[++cnt].to = y;
  e[cnt].nex = head[x];
  head[x] = cnt;
}
void dfs(int x, int fa) {
  d[x] = d[fa] + 1;
  f[x] = fa;
  for (int i = head[x]; i; i = e[i].nex) {
    int y = e[i].to;
    if (!d[y])
      dfs(y, x);
    else if (d[y] < d[x] && y != fa)
      --size[y], ++size[x];
  }
  size[fa] += size[x];
}
void DFS(int x) {
  for (int i = head[x]; i; i = e[i].nex) {
    int y = e[i].to;
    if (d[y] == d[x] + 1) {
      DFS(y);
      if (l2) return;
    } else if (d[y] < d[s] && y != f[x]) {
      if (l1)
        r2 = x, l2 = y;
      else
        r1 = x, l1 = y;
      if (l2) return;
    }
  }
}
int q[N];
void go(int l, int r) {
  int k = t;
  t += abs(d[l] - d[r]) + 1;
  if (d[l] > d[r])
    for (int i = l, j = k + 1; j <= t; i = f[i], ++j) q[j] = i;
  else
    for (int i = r, j = t; j > k; i = f[i], --j) q[j] = i;
}
void print() {
  printf("%d ", t);
  for (int i = 1; i <= t; ++i) printf("%d ", q[i]);
  puts("");
}
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 (!d[i]) dfs(i, 0);
  for (int i = 1; i <= n; ++i)
    if (size[i] > 1) {
      s = i;
      break;
    }
  if (!s)
    puts("NO");
  else {
    DFS(s);
    puts("YES");
    if (d[l1] > d[l2]) swap(l1, l2), swap(r1, r2);
    for (a = r1, b = r2; a != b;) {
      if (d[a] > d[b])
        a = f[a];
      else
        b = f[b];
    }
    t = 0;
    go(a, r1);
    go(l1, l2);
    print();
    t = 0;
    go(a, r2);
    go(l2, l2);
    print();
    t = 0;
    go(a, l2);
    print();
    return 0;
  }
}
