#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
vector<vector<long long>> g1(200005, vector<long long>());
vector<long long> ans(200005, -1);
void dfs(long long n, long long color) {
  ans[n] = color;
  for (auto x1 : g1[n]) {
    if (ans[x1] == -1)
      dfs(x1, color ^ 1);
    else if (ans[n] == ans[x1]) {
      cout << -1 << endl;
      exit(0);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, i;
  cin >> n >> m;
  ans = vector<long long>(n + 1, -1);
  for (i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    g1[a].push_back(b);
    g1[b].push_back(a);
  }
  for (i = 1; i < n + 1; i++) {
    if (ans[i] == -1) {
      dfs(i, 0);
    }
  }
  long long zero = count(ans.begin(), ans.end(), 0);
  long long one = count(ans.begin(), ans.end(), 1);
  cout << one << endl;
  for (i = 1; i < n + 1; i++) {
    if (ans[i] == 1) cout << i << " ";
  }
  cout << endl;
  cout << zero << endl;
  for (i = 1; i < n + 1; i++) {
    if (ans[i] == 0) cout << i << " ";
  }
  cout << endl;
}
