#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int mod = 998244353;
int Mod(long long x) { return x >= mod ? x - mod : x; }
long long read() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
  return x * f;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 200010, M = N;
int n, m;
;
struct edge {
  int nxt, to, w;
} e[M << 1];
int head[N], ecnt = 1;
void add(int u, int v, long long w = 0) {
  e[++ecnt].w = w, e[ecnt].to = v, e[ecnt].nxt = head[u];
  head[u] = ecnt;
}
void add_edge(int u, int v, long long w = 0) {
  add(u, v, w), add(v, u, w * 1);
};
int fa[N], dep[N];
bool ins[N];
int fr[N], to[N];
int lca(int x, int y) {
  while (dep[x] > dep[y]) x = fa[x];
  while (dep[y] > dep[x]) y = fa[y];
  while (x != y) x = fa[x], y = fa[y];
  return x;
}
int tmp[N], cnt;
void add_path(int x, int y) {
  while (x != y) tmp[++cnt] = x, x = fa[x];
  tmp[++cnt] = y;
}
void print() {
  print(cnt), putchar(' ');
  for (int i = 1; i <= cnt; i++) print(tmp[i]), putchar(' ');
  putchar('\n');
}
void get_ans(int a, int b, int c, int d) {
  if (dep[b] > dep[d]) swap(a, c), swap(b, d);
  int z = lca(a, c);
  puts("YES");
  add_path(z, d), reverse(tmp + 1, tmp + 1 + cnt);
  print(), cnt = 0;
  add_path(d, b), add_path(a, z);
  print(), cnt = 0;
  tmp[cnt = 1] = d, add_path(c, z);
  print();
  exit(0);
}
void dfs(int u) {
  dep[u] = dep[fa[u]] + 1;
  ins[u] = 1;
  for (int i = head[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != fa[u]) {
      if (!dep[v])
        fa[v] = u, dfs(v);
      else if (ins[v]) {
        for (int k = u; k != v; k = fa[k])
          if (fr[k])
            get_ans(fr[k], to[k], u, v);
          else
            fr[k] = u, to[k] = v;
      }
    }
  ins[u] = 0;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) add_edge(read(), read());
  for (int i = 1; i <= n; i++)
    if (!dep[i]) dfs(i);
  puts("NO");
  return 0;
}
