#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
bool flag;
int n, m;
int c[100005];
vector<int> a[2], e[100005];
void dfs(int x, int t) {
  if (c[x] != -1) {
    if (c[x] != t) flag = 1;
    return;
  }
  c[x] = t;
  a[t].push_back(x);
  for (int i = 0; i < e[x].size(); i++) dfs(e[x][i], t ^ 1);
}
void output(vector<int> &x) {
  printf("%d\n", x.size());
  for (int i = 0; i < x.size() - 1; i++) {
    printf("%d ", x[i]);
  }
  printf("%d\n", x[x.size() - 1]);
}
int main() {
  memset(c, -1, sizeof(c));
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    e[u].push_back(v);
    e[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (c[i] == -1) dfs(i, 1);
  if (flag)
    puts("-1\n");
  else {
    sort(a[0].begin(), a[0].end());
    sort(a[1].begin(), a[1].end());
    if (a[0].size() < a[1].size()) {
      output(a[0]);
      output(a[1]);
    } else {
      output(a[1]);
      output(a[0]);
    }
  }
  return 0;
}
