#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  vector<vector<long long int> > g(n + 1, std::vector<long long int>(0));
  vector<long long> color(n + 1, -1);
  queue<long long> q;
  for (long long i = 0; i < m; i++) {
    int s, d;
    cin >> s;
    cin >> d;
    g[s].push_back(d);
    g[d].push_back(s);
  }
  vector<int> s1;
  vector<int> s2;
  for (int i = 1; i <= n; i++) {
    if (color[i] == -1) {
      color[i] = 1;
      q.push(i);
      if (color[i] == 1)
        s1.push_back(i);
      else
        s2.push_back(i);
      while (!q.empty()) {
        long long curr = q.front();
        q.pop();
        for (long long ne : g[curr]) {
          if (color[ne] == color[curr]) {
            cout << "-1" << endl;
            return 0;
          } else if (color[ne] == -1) {
            color[ne] = 1 - color[curr];
            q.push(ne);
            if (color[ne] == 1)
              s1.push_back(ne);
            else
              s2.push_back(ne);
          }
        }
      }
    }
  }
  cout << s1.size() << endl;
  for (unsigned long long int i = 0; i < s1.size(); ++i) {
    cout << s1[i] << " ";
  }
  cout << endl;
  cout << s2.size() << endl;
  for (unsigned long long int i = 0; i < s2.size() - 1; ++i) {
    cout << s2[i] << " ";
  }
  cout << s2[s2.size() - 1] << endl;
}
