#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 5;
int n, m;
vector<vector<int>> adj;
int Set[N];
bool vis[N];
bool isBipartite(int node) {
  for (int& x : adj[node]) {
    if (!vis[x]) {
      vis[x] = 1;
      Set[x] = 3 - Set[node];
      if (!isBipartite(x)) return false;
    } else if (Set[x] == Set[node])
      return false;
  }
  return true;
}
int solve() {
  scanf("%d%d", &n, &m);
  adj = vector<vector<int>>(n + 1);
  int V = -1;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = 1;
      Set[i] = 1;
      bool res = isBipartite(i);
      if (!res) return puts("-1"), 0;
    }
  }
  int A = 0, P = 0;
  for (int i = 1; i <= n; i++) {
    A += Set[i] == 1;
    P += Set[i] == 2;
  }
  printf("%d\n", A);
  for (int i = 1; i <= n; i++)
    if (Set[i] == 1) printf("%d ", i);
  printf("\n");
  printf("%d\n", P);
  for (int i = 1; i <= n; i++)
    if (Set[i] == 2) printf("%d ", i);
  return 0;
}
int main() { solve(); }
