#include <bits/stdc++.h>
std::vector<int> adj[100000];
bool bipartite = true;
int color[100000];
bool visited[100000];
int count[2];
void dfs(int v, int c) {
  if (visited[v]) return;
  visited[v] = true;
  color[v] = c;
  count[c]++;
  for (int u : adj[v]) {
    if (!visited[u]) {
      dfs(u, 1 - c);
    } else {
      if (color[u] == color[v]) {
        bipartite = false;
      }
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    std::cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) dfs(i, 0);
    if (!bipartite) break;
  }
  if (bipartite) {
    for (int c = 0; c < 2; ++c) {
      std::cout << count[c] << '\n';
      for (int i = 0; i < n; ++i) {
        if (color[i] == c) std::cout << (i + 1) << ' ';
      }
      std::cout << '\n';
    }
  } else {
    std::cout << -1 << '\n';
  }
  return 0;
}
