#include <bits/stdc++.h>
using namespace std;
inline void fast_and_furious() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int n, m, u, v;
vector<int> node[100005], visited(100005), alloc(100005), one, two;
int part_of_any_edge[100005];
void dfs(int current) {
  visited[current] = true;
  for (auto child : node[current]) {
    if (!alloc[child]) {
      if (alloc[current] == 1)
        alloc[child] = 2;
      else
        alloc[child] = 1;
    } else if (alloc[child] == alloc[current]) {
      cout << "-1";
      exit(0);
    }
    if (!visited[child]) dfs(child);
  }
}
int main() {
  fast_and_furious();
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    part_of_any_edge[u] = true;
    part_of_any_edge[v] = true;
    node[u].emplace_back(v);
    node[v].emplace_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i] && (part_of_any_edge[u] == true)) dfs(i);
  }
  for (int i = 1; i <= n; i++) {
    if (part_of_any_edge[u] = true) {
      if (alloc[i] == 1) one.emplace_back(i);
      if (alloc[i] == 2) two.emplace_back(i);
    }
  }
  cout << (int)one.size() << "\n";
  for (auto it : one) cout << it << " ";
  cout << "\n";
  cout << (int)two.size() << "\n";
  for (auto it : two) cout << it << " ";
  return 0;
}
