#include <bits/stdc++.h>   using namespace std;   vector<int> edges[100006];   int given[100006] = {0};   int dfs(int i, int c) {     if (given[i] != 0) {       if ((given[i] == 1 && c == 2) || (given[i] == 2 && c == 1)) return 0;     }     if (edges[i].size() != 0) given[i] = c;     int fl = 1;     for (int j = 0; j < edges[i].size(); j++) {       int v = edges[i][j];       if (given[v] != 0) {         if (given[v] == c) return 0;       } else {         int t;         if (c == 1)           t = 2;         else           t = 1;         fl = dfs(v, t) & fl;       }     }     return fl;   }   int main() {     int u, v, n, m;     scanf( %d , &n), scanf( %d , &m);     for (int i = (0); i < (m); ++i) {       scanf( %d , &u), scanf( %d , &v);       edges[u].push_back(v);       edges[v].push_back(u);     }     for (int i = (0); i < (100004); ++i) given[i] = 0;     int flag = 1;     for (int i = 1; i <= n && flag; i++) {       if (given[i] == 0) flag = dfs(i, 1) & flag;     }     if (flag == 0)       puts( -1 );     else {       int a = 0, s = 0, tempp = 22;       for (int i = 1; i <= n; i++)         if (given[i] == 1)           a++;         else if (given[i] == 2)           s++;       printf( %d n , a);       for (int i = 1; i <= n; i++)         if (given[i] == 1) printf( %d  , i);       printf(  n );       printf( %d n , s);       for (int i = 0; i <= n; i++)         if (given[i] == 2) printf( %d  , i);       printf(  n );     }   }   