#include <bits/stdc++.h>
using namespace std;
int vis[200010];
int addnum, vel[400010], head[400010], ne[400010];
int fath[200010][21];
int fa[200010], dep[200010];
pair<int, int> s[200010];
int tot, n, m;
vector<int> o, o1, o2;
int id[11];
int d[200010], f[200010][2];
int num;
int p[200010];
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  return ans;
}
inline int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
void dfs(int u, int fa) {
  vis[u] = 1;
  for (int e = head[u]; e; e = ne[e]) {
    int v = vel[e];
    if (v == fa) continue;
    fath[v][0] = u;
    dep[v] = dep[u] + 1;
    dfs(v, u);
  }
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int dt = dep[x] - dep[y];
  for (int i = 19; i >= 0; i--)
    if (dt >> i & 1) x = fath[x][i];
  for (int i = 19; i >= 0; i--)
    if (fath[x][i] != fath[y][i]) x = fath[x][i], y = fath[y][i];
  if (x == y) return x;
  return fath[x][0];
}
void calc(int num) {
  int x = s[num].first, y = s[num].second;
  int dt = lca(x, y);
  o1.clear(), o2.clear();
  while (x != dt) o1.push_back(x), x = fath[x][0];
  o1.push_back(dt);
  while (y != dt) o2.push_back(y), y = fath[y][0];
  while (o1.size()) o2.push_back(o1.back()), o1.pop_back();
  o.clear();
  int pos = 0, cnt = o2.size();
  for (int i = 0; i < cnt; i++)
    if (p[o2[i]] == 1 && !p[o2[(i + 1) % cnt]]) {
      pos = i;
      break;
    }
  o.push_back(id[0] == o2[pos] ? id[0] : id[1]);
  for (int i = pos + 1; i < cnt + pos; i++)
    if (p[o2[i % cnt]])
      break;
    else
      o.push_back(o2[i % cnt]);
  o.push_back(id[0] == o2[pos] ? id[1] : id[0]);
  printf("%d ", (int)o.size());
  if (o.back() != id[0]) reverse(o.begin(), o.end());
  while (o.size()) {
    int u = o.back();
    o.pop_back();
    printf("%d%c", u, !o.size() ? '\n' : ' ');
  }
}
void add(int u, int v) {
  addnum++, vel[addnum] = v, ne[addnum] = head[u], head[u] = addnum;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    if (find(x) != find(y))
      fa[find(x)] = find(y), add(x, y), add(y, x);
    else
      s[++tot] = make_pair(x, y);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, -1);
  for (int i = 1; i < 20; i++)
    for (int j = 1; j <= n; j++) fath[j][i] = fath[fath[j][i - 1]][i - 1];
  for (int i = 1; i <= tot; i++) {
    int x = s[i].first, y = s[i].second;
    while (x != y) {
      if (dep[x] < dep[y]) swap(x, y);
      if (!d[x])
        d[x] = i;
      else {
        num = d[x];
        break;
      }
      x = fath[x][0];
    }
    if (num) {
      printf("YES\n");
      x = s[i].first, y = s[i].second;
      while (x != y) {
        if (dep[x] < dep[y]) swap(x, y);
        f[x][0] = 1;
        x = fath[x][0];
      }
      x = s[num].first, y = s[num].second;
      while (x != y) {
        if (dep[x] < dep[y]) swap(x, y);
        f[x][1] = 1;
        x = fath[x][0];
      }
      for (int i = 1; i <= n; i++)
        if (f[i][0] && f[i][1]) p[fath[i][0]]++, p[i]++;
      int cnt = 0;
      for (int i = 1; i <= n; i++)
        if (p[i] == 1) id[cnt++] = i;
      x = id[0];
      y = id[1];
      while (p[x]) o1.push_back(x), x = fath[x][0];
      while (p[y]) o2.push_back(y), y = fath[y][0];
      printf("%d ", (int)(o1.size() + o2.size() - 1));
      for (int i = 0; i < (int)o1.size() - 1; i++) printf("%d ", o1[i]);
      while (o2.size()) {
        int u = o2.back();
        o2.pop_back();
        printf("%d%c", u, !o2.size() ? '\n' : ' ');
      }
      calc(i), calc(num);
      return 0;
    }
  }
  printf("NO\n");
}
