#include <bits/stdc++.h>
using namespace std;
vector<int> e[200005], ans;
int n, m, num, timer, d[200005], pre[200005], dfn[200005];
bool ok[200005];
pair<int, int> tag[200005];
inline vector<int> add(vector<int> a, vector<int> b) {
  for (int i = 0; i < b.size(); i++) a.push_back(b[i]);
  return a;
}
inline vector<int> reverse(vector<int> a) {
  if (a.size() == 0) return a;
  vector<int> b;
  for (int i = a.size() - 1; i >= 0; i--) b.push_back(a[i]);
  return b;
}
inline vector<int> combine(int x, int y) {
  vector<int> a;
  if (d[x] < d[y]) {
    int t = x;
    x = y;
    y = t;
  }
  while (x != y) {
    a.push_back(x);
    x = pre[x];
  }
  a.push_back(y);
  return a;
}
inline void getans(int s1, int t1, int s2, int t2, int x) {
  printf("YES\n");
  if (d[s1] < d[s2]) {
    int t = s1;
    s1 = s2;
    s2 = t;
    t = t1;
    t1 = t2;
    t2 = t;
  }
  if (d[t1] > d[t2]) {
    int t = s1;
    s1 = s2;
    s2 = t;
    t = t1;
    t1 = t2;
    t2 = t;
  }
  ans = combine(x, t2);
  printf("%d ", ans.size());
  for (int i = 0; i < ans.size() - 1; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[ans.size() - 1]);
  ans = reverse(combine(s2, x));
  ans.push_back(t2);
  printf("%d ", ans.size());
  for (int i = 0; i < ans.size() - 1; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[ans.size() - 1]);
  ans = add(reverse(combine(s1, x)), reverse(combine(t2, t1)));
  printf("%d ", ans.size());
  for (int i = 0; i < ans.size() - 1; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[ans.size() - 1]);
  exit(0);
}
inline void make_tag(int s, int t) {
  int i = s;
  while (i != t) {
    if (tag[i].first != 0) getans(tag[i].first, tag[i].second, s, t, i);
    tag[i] = make_pair(s, t);
    i = pre[i];
  }
}
inline void dfs(int now, int fa) {
  ok[now] = true;
  dfn[now] = ++timer;
  pre[now] = fa;
  d[now] = d[fa] + 1;
  for (int i = 0; i < e[now].size(); i++)
    if (e[now][i] != fa) {
      if (dfn[e[now][i]] == 0)
        dfs(e[now][i], now);
      else if (dfn[e[now][i]] < dfn[now])
        make_tag(now, e[now][i]);
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!ok[i]) dfs(i, 0);
  printf("NO\n");
  return 0;
}
