#include <bits/stdc++.h>
struct Side {
  int to;
  int next;
  Side() { to = next = 0; }
  Side(int a, int b) {
    to = a;
    next = b;
  }
};
int n, m;
int sidecnt = 1;
int head[200001];
Side sides[200001 << 1];
bool visited[200001];
bool ins[200001];
int depth[200001];
int fa[200001];
std::pair<int, int> tag[200001];
int tmpcnt;
int tmp[200001];
void inline Swap(int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
void inline adde(int x, int y) {
  sides[++sidecnt] = Side(y, head[x]);
  head[x] = sidecnt;
}
int lca(int x, int y) {
  while (depth[x] > depth[y]) {
    x = fa[x];
  }
  while (depth[y] > depth[x]) {
    y = fa[y];
  }
  while (x != y) {
    x = fa[x];
    y = fa[y];
  }
  return x;
}
void add(int x, int y) {
  while (x != y) {
    tmp[++tmpcnt] = x;
    x = fa[x];
  }
  tmp[++tmpcnt] = x;
}
void addrev(int x, int y) {
  if (x != y) {
    addrev(fa[x], y);
  }
  tmp[++tmpcnt] = x;
}
void print() {
  printf("%d ", tmpcnt);
  for (int i = 1; i <= tmpcnt; i++) {
    printf("%d ", tmp[i]);
  }
  puts("");
  tmpcnt = 0;
}
void calc(int a, int b, int c, int d) {
  puts("YES");
  if (depth[b] > depth[d]) {
    Swap(a, c);
    Swap(b, d);
  }
  int e = lca(a, c);
  addrev(e, d);
  print();
  add(d, b);
  add(a, e);
  print();
  tmp[++tmpcnt] = d;
  add(c, e);
  print();
  exit(0);
}
void cover(int x, int y) {
  if (depth[x] < depth[y]) {
    Swap(x, y);
  }
  int a = x;
  while (a != y) {
    if (tag[a].first && tag[a].second) {
      calc(tag[a].first, tag[a].second, x, y);
    }
    tag[a] = std::make_pair(x, y);
    a = fa[a];
  }
}
void dfs(int x) {
  depth[x] = depth[fa[x]] + 1;
  visited[x] = true;
  ins[x] = true;
  int next = head[x];
  while (next != 0) {
    int y = sides[next].to;
    if (y != fa[x]) {
      if (!visited[y]) {
        fa[y] = x;
        dfs(y);
      } else if (ins[y]) {
        cover(x, y);
      }
    }
    next = sides[next].next;
  }
  ins[x] = false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    adde(x, y);
    adde(y, x);
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  puts("NO");
  return 0;
}
