#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, id[maxn];
vector<int> a[maxn];
void print(const vector<int>& v) {
  cout << (int)v.size() << "\n";
  for (int i = 0; i < (int)v.size(); ++i) cout << v[i] << " ";
  cout << "\n";
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  queue<int> q;
  for (int r = 1; r <= n; ++r)
    if (id[r] == 0) {
      id[r] = 1;
      q.push(r);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = 0; i < (int)a[u].size(); ++i) {
          int v = a[u][i];
          if (id[v] == 0) {
            id[v] = 3 - id[u];
            q.push(v);
          } else if (id[v] == id[u]) {
            cout << "-1\n";
            return 0;
          }
        }
      }
    }
  vector<int> x, y;
  for (int i = 1; i <= n; ++i)
    if (id[i] == 1)
      x.push_back(i);
    else
      y.push_back(i);
  print(x);
  print(y);
}
