#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
using vll = int64_t;
const int N = 1e6 + 1;
vector<int> adj[N];
vector<bool> vis(N, false);
vector<short> col(N, -1);
inline bool bfs(int src) {
  queue<pair<int, int>> q;
  q.push({src, 0});
  vis[src] = true;
  col[src] = 0;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    for (int i : adj[p.first]) {
      if (vis[i]) {
        if (col[i] == col[p.first]) {
          return false;
        }
        continue;
      }
      vis[i] = true;
      col[i] = (p.second == 1 ? 0 : 1);
      q.push({i, col[i]});
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int m;
  cin >> m;
  unordered_set<int> hs;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    hs.insert(a);
    hs.insert(b);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i] && hs.find(i) != hs.end()) {
      bool ok = bfs(i);
      if (!ok) {
        cout << "-1\n";
        return 0;
      }
    }
  }
  int red = 0, black = 0;
  for (int i = 0; i < n; i++) {
    if (col[i] == 1)
      black++;
    else if (col[i] == 0)
      red++;
  }
  cout << red << "\n";
  for (int i = 0; i < n; i++) {
    if (col[i] == 0) cout << 1 + i << " ";
  }
  cout << "\n";
  cout << black << "\n";
  for (int i = 0; i < n; i++) {
    if (col[i] == 1) cout << i + 1 << " ";
  }
  return 0;
}
