#include <bits/stdc++.h>
using namespace std;
int col[300000];
vector<int> st[3];
vector<int> adj[300000];
bool bad;
void dfs(int v, int c) {
  if (col[v]) return;
  col[v] = c;
  st[c].push_back(v);
  for (int i = 0; i < adj[v].size(); i++) {
    if (col[adj[v][i]] != 0 and col[adj[v][i]] != 3 - c) {
      bad = 1;
      return;
    }
    if (col[adj[v][i]] == 0) dfs(adj[v][i], 3 - c);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!col[i]) dfs(i, 1);
    if (bad) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (bad) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= 2; i++) {
    cout << st[i].size();
    cout << endl;
    for (int j = 0; j < st[i].size(); j++) cout << st[i][j] << " ";
    cout << endl;
  }
  return 0;
}
