#include <bits/stdc++.h>

using namespace std;

bool custom(pair<int64_t, vector<int64_t> > a, pair<int64_t, vector<int64_t> > b){
    // if(a.second.size()==b.second.size())
    //     return a.first > b.first;
    return a.second.size() > b.second.size();
}

bool customS1(pair<int, int> a, pair<int, int> b){
    // if(a.second==b.second)
    //     return a.first > b.first;
    return a.second < b.second;
}

bool customS2(pair<int, int> a, pair<int, int> b){
    if((a.first+a.second)==(b.first+b.second))
        return a.second < b.second;
    return (a.first+a.second)<(b.first+b.second);
}

class CompareDist
{
public:
    bool operator()(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b){
        return a.first < b.first;
    }
};

int64_t gcd(int64_t a, int64_t b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

double gcdfloat(double a, double b) {
    if (a < b)
        return gcd(b, a);

    if (fabs(b) < 0.001)
        return a;

    else
        return (gcd(b, a - floor(a / b) * b));
}

// vector<int64_t> colors(200001, -1);
// // queue<int> q;

// void DFS(int64_t start, int64_t c1, int64_t c2){
//     // cout<<start<<" ";
//     colors[start] = c2;
//     visited[start] = 1;
//     // *ctr = *ctr + 1;
//     // cout<<start<<" "<<*ctr<<"\n";
//     // int t = nodes[start].size();
//     // *max_degree = max(*max_degree, t);
//     // bool temp=false;
//     // cout<<start<<" "<<initial[start]<<" "<<after[start]<<"\n";
//     int64_t color_ctr=1;
//     for(int i=0;i<nodes[start].size();i++){
//         if(visited[nodes[start][i]]==0){
//             while(color_ctr==c1 || color_ctr==c2)
//                 color_ctr++;

//             DFS(nodes[start][i], c2, color_ctr);
//             color_ctr += 1;

//         }
//     }
// }

int64_t LCA(int64_t a, int64_t b){
    while(a!=b){
        // cout<<a<<" "<<b<<"\n";
        if(b>a){
            swap(a, b);
        }
        a /= 2;
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, a, b, i, j;
    cin>>n>>m;
    vector<vector<int> > nodes(n+1);
    for(i=0;i<m;i++){
        cin>>a>>b;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    // cout<<"done;";
    vector<int> partition(n+1, -1); // visited(n+1, 0),
    for(i=1;i<n+1;i++){
        if(partition[i]==-1){
            queue<int> q;
            q.push(i);
            // q.push(-1);
            partition[i] = 0;
            int flag = 1;
            while(!q.empty()){
                int temp = q.front();
                q.pop();
                if(partition[temp]==0)
                    flag = 1;
                else
                    flag = 0;
                // if(temp==-1){
                //     if(!q.empty())
                //         q.push(-1);
                //     flag = flag ^ 1;
                //     continue;
                // }
                // cout<<"f "<<flag<<" "<<temp<<"\n";
                for(j=0;j<nodes[temp].size();j++){
                    // cout<<"p "<<nodes[temp][j]<<" "<<partition[nodes[temp][j]]<<"\n";
                    if(partition[nodes[temp][j]]==-1){
                        partition[nodes[temp][j]] = flag;
                        q.push(nodes[temp][j]);
                    }
                    else if(partition[nodes[temp][j]]==partition[temp]){
                        cout<<"-1\n";
                        return 0;
                    }
                }
            }
        }
        break;
    }
    vector<int> nodes_1, nodes_2;
    for(i=1;i<=n;i++){
        if(partition[i]==0)
            nodes_1.push_back(i);
        else if(partition[i]==1)
            nodes_2.push_back(i);
    }
    cout<<nodes_1.size()<<"\n";
    for(i=0;i<nodes_1.size();i++)
        cout<<nodes_1[i]<<" ";
    cout<<"\n";
    cout<<nodes_2.size()<<"\n";
    for(i=0;i<nodes_2.size();i++)
        cout<<nodes_2[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool custom(pair<int64_t, vector<int64_t> > a, pair<int64_t, vector<int64_t> > b){
    // if(a.second.size()==b.second.size())
    //     return a.first > b.first;
    return a.second.size() > b.second.size();
}

bool customS1(pair<int, int> a, pair<int, int> b){
    // if(a.second==b.second)
    //     return a.first > b.first;
    return a.second < b.second;
}

bool customS2(pair<int, int> a, pair<int, int> b){
    if((a.first+a.second)==(b.first+b.second))
        return a.second < b.second;
    return (a.first+a.second)<(b.first+b.second);
}

class CompareDist
{
public:
    bool operator()(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b){
        return a.first < b.first;
    }
};

int64_t gcd(int64_t a, int64_t b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

double gcdfloat(double a, double b) {
    if (a < b)
        return gcd(b, a);

    if (fabs(b) < 0.001)
        return a;

    else
        return (gcd(b, a - floor(a / b) * b));
}

// vector<int64_t> colors(200001, -1);
// // queue<int> q;

// void DFS(int64_t start, int64_t c1, int64_t c2){
//     // cout<<start<<" ";
//     colors[start] = c2;
//     visited[start] = 1;
//     // *ctr = *ctr + 1;
//     // cout<<start<<" "<<*ctr<<"\n";
//     // int t = nodes[start].size();
//     // *max_degree = max(*max_degree, t);
//     // bool temp=false;
//     // cout<<start<<" "<<initial[start]<<" "<<after[start]<<"\n";
//     int64_t color_ctr=1;
//     for(int i=0;i<nodes[start].size();i++){
//         if(visited[nodes[start][i]]==0){
//             while(color_ctr==c1 || color_ctr==c2)
//                 color_ctr++;

//             DFS(nodes[start][i], c2, color_ctr);
//             color_ctr += 1;

//         }
//     }
// }

int64_t LCA(int64_t a, int64_t b){
    while(a!=b){
        // cout<<a<<" "<<b<<"\n";
        if(b>a){
            swap(a, b);
        }
        a /= 2;
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, a, b, i, j;
    cin>>n>>m;
    vector<vector<int> > nodes(n+1);
    for(i=0;i<m;i++){
        cin>>a>>b;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    // cout<<"done;";
    vector<int> partition(n+1, -1); // visited(n+1, 0),
    for(i=1;i<n+1;i++){
        if(partition[i]==-1){
            queue<int> q;
            q.push(i);
            q.push(-1);
            // visited[i] = 1;
            partition[i] = 0;
            int flag = 1;
            while(!q.empty()){
                int temp = q.front();
                q.pop();
                if(temp==-1){
                    flag = flag ^ 1;
                    continue;
                }
                // cout<<"f "<<flag<<" "<<temp<<"\n";
                for(j=0;j<nodes[temp].size();j++){
                    // cout<<"p "<<nodes[temp][j]<<" "<<partition[nodes[temp][j]]<<"\n";
                    if(partition[nodes[temp][j]]==-1){
                        partition[nodes[temp][j]] = flag;
                        q.push(nodes[temp][j]);
                    }
                    else if(partition[nodes[temp][j]]==partition[temp]){
                        cout<<"-1\n";
                        return 0;
                    }
                }
            }
        }
        break;
    }
    vector<int> nodes_1, nodes_2;
    for(i=1;i<=n;i++){
        if(partition[i]==0)
            nodes_1.push_back(i);
        else if(partition[i]==1)
            nodes_2.push_back(i);
    }
    cout<<nodes_1.size()<<"\n";
    for(i=0;i<nodes_1.size();i++)
        cout<<nodes_1[i]<<" ";
    cout<<"\n";
    cout<<nodes_2.size()<<"\n";
    for(i=0;i<nodes_2.size();i++)
        cout<<nodes_2[i]<<" ";
    cout<<"\n";
    return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	int n, m, a, b ;
    cin >> n >> m ;
	vector< vector<int> > gr(n);
	vector<int> grupo(n,0);
	int v1 = 0;
	int v2 = 0;

    for (int i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    int j = 0 ;
    while(j<n){

    	if(gr[j].empty()){j++;}
    	else{
		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<int> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1++;
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				int u = q.front(); q.pop() ;
				for(int v : gr[u]) {
					if(grupo[v]!=0) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
					}
					else{
						if(grupo[u]==1){grupo[v]=2; v2++;}
						else{grupo[v]=1; v1++;}
						q.push(v);
					}
				}
			}

			if(n == v1+v2){break;}
			else{
				for (int i = 0; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
				}
			}
		}

	}

	cout << v1 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	long long n, m, a, b, c ;
    cin >> n >> m ;
	vector< vector<long long> > gr(n);
	vector<long long> grupo(n,3);
	vector<long long> v1;
	vector<long long> v2;

    for (long long i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    	grupo[a]=0;
    	grupo[b]=0;
    }

    long long j = 0 ;
    while(true){

		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<long long> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1.push_back(j);
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				long long u = q.front(); q.pop() ;
				for(long long v : gr[u]) {
					if(grupo[v]==1 || grupo[v]==2) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){
							cout << -1 << endl;
							return 0;}
					}
					else if(grupo[v]==0){
						if(grupo[u]==1){
							grupo[v]=2;
							v2.push_back(v);
						}
						else if(grupo[u]==2){
							grupo[v]=1;
							v1.push_back(v);
						}
						q.push(v);
					}
				}
			}

			if(n == v1.size()+v2.size()){break;}
			else{
				int b =0;
				for (long long i = j; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
					if(i==n-1){b=1;}
				}
				if(b ==1){break;}
			}

	}

	cout << v1.size() << endl ;
	for (long long i = 0; i < v1.size(); ++i) {
		cout << v1[i] + 1 << " " ;
	}
	cout << endl << v2.size() << endl ;
	for (long long i = 0; i < v2.size(); ++i) {
		cout << v2[i] + 1 << " " ;
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	int n, m, a, b ;
    cin >> n >> m ;
	vector< vector<int> > gr(n);
	vector<int> grupo(n,0);
	int v1 = 0;
	int v2 = 0;

    for (int i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    for (int i = 0; i < n; ++i) {
    	if(gr[i].empty()){grupo[i] = 3;}
    }

    int j = 0 ;
    while(true){

		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<int> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1++;
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				int u = q.front(); q.pop() ;
				for(int v : gr[u]) {
					if(grupo[v]==1 || grupo[v]==2) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
					}
					else if(grupo[v]==0){
						if(grupo[u]==1){grupo[v]=2; v2++;}
						else{grupo[v]=1; v1++;}
						q.push(v);
					}
				}
			}

			if(n == v1+v2){break;}
			else{
				for (int i = 0; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
				}
			}

	}

	cout << v1 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	int n, m, a, b ;
    cin >> n >> m ;
	vector< vector<int> > gr(n);
	vector<int> grupo(n,0);
	int v1 = 0;
	int v2 = 0;

    for (int i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    // Recorrer grafo y contar numero de vertices por grupo
    queue<int> q; q.push(0) ;
    grupo[0] = 1 ; // Poner primer nodo en grupo 1
    v1++;
	// Iteraciones sobre la cola
	while(!q.empty()) {
		// Sacar un elemento de la cola
		int u = q.front(); q.pop() ;
		for(int v : gr[u]) {
			if(grupo[v]!=0) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
				if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
			}
			else{
				if(grupo[u]==1){grupo[v]=2; v2++;}
				else{grupo[v]=1; v1++;}
				q.push(v);
			}
		}
	}

	cout << v1 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	long long n, m, a, b, c ;
    cin >> n >> m ;
	vector< vector<long long> > gr(n);
	vector<long long> grupo(n,0);
	long long v1 = 0;
	long long v2 = 0;

    for (long long i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    for (long long i = 0; i < n; ++i) {
    	if(gr[i].empty()){grupo[i] = 3;}
    }

    long long j = 0 ;
    while(true){

		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<long long> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1++;
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				long long u = q.front(); q.pop() ;
				for(long long v : gr[u]) {
					if(grupo[v]==1 || grupo[v]==2) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
					}
					else if(grupo[v]==0){
						if(grupo[u]==1){grupo[v]=2; v2++;q.push(v);}
						else if(grupo[u]==2){grupo[v]=1; v1++;q.push(v);}
					}
				}
			}

			if(n == v1+v2){break;}
			else{
				int b =0;
				for (long long i = 0; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
					if(i==n-1){b=1;}
				}
				if(b ==1){break;}
			}

	}

	cout << v1 << endl ;
	for (long long i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (long long i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}
	//cout << c ;
	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	int n, m, a, b ;
    cin >> n >> m ;
	vector< vector<int> > gr(n);
	vector<int> grupo(n,0);
	int v1 = 0;
	int v2 = 0;

    for (int i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    int j = 0 ;
    while(true){

	    // Recorrer grafo y contar numero de vertices por grupo
	    queue<int> q; q.push(j) ;
	    grupo[j] = 1 ; // Poner primer nodo en grupo 1
	    v1++;
		// Iteraciones sobre la cola
		while(!q.empty()) {
			// Sacar un elemento de la cola
			int u = q.front(); q.pop() ;
			for(int v : gr[u]) {
				if(grupo[v]!=0) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
					if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
				}
				else{
					if(grupo[u]==1){grupo[v]=2; v2++;}
					else{grupo[v]=1; v1++;}
					q.push(v);
				}
			}
		}

		if(n == v1+v2){break;}
		else{
			for (int i = 0; i < n; ++i) {
				if(grupo[i]==0){j=i;}
			}
		}

	}

	cout << v1 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	long long n, m, a, b, c ;
    cin >> n >> m ;
	vector< vector<long long> > gr(n);
	vector<long long> grupo(n,3);
	vector<long long> v1;
	vector<long long> v2;

    for (long long i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    	grupo[a]=0;
    	grupo[b]=0;
    }

    long long j = 0 ;
    while(true){

		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<long long> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1.push_back(j);
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				long long u = q.front(); q.pop() ;
				for(long long v : gr[u]) {
					if(grupo[v]==1 || grupo[v]==2) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){
							cout << -1 << endl;
							return 0;}
					}
					else if(grupo[v]==0){
						if(grupo[u]==1){
							grupo[v]=2;
							v2.push_back(v);
						}
						else if(grupo[u]==2){
							grupo[v]=1;
							v1.push_back(v);
						}
						q.push(v);
					}
				}
			}

			if(n == v1.size()+v2.size()){break;}
			else{
				int b =0;
				for (long long i = 0; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
					if(i==n-1){b=1;}
				}
				if(b ==1){break;}
			}

	}

	cout << v1.size() << endl ;
	for (long long i = 0; i < v1.size(); ++i) {
		cout << v1[i] + 1 << " " ;
	}
	cout << endl << v2.size() << endl ;
	for (long long i = 0; i < v2.size(); ++i) {
		cout << v2[i] + 1 << " " ;
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	int n, m, a, b ;
    cin >> n >> m ;
	vector< vector<int> > gr(n);
	vector<int> grupo(n,0);
	int v1 = 0;
	int v2 = 0;

    for (int i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    int j = 0 ;
    while(true){

	    // Recorrer grafo y contar numero de vertices por grupo
	    queue<int> q; q.push(j) ;
	    grupo[j] = 1 ; // Poner primer nodo en grupo 1
	    v1++;
		// Iteraciones sobre la cola
		while(!q.empty()) {
			// Sacar un elemento de la cola
			int u = q.front(); q.pop() ;
			for(int v : gr[u]) {
				if(grupo[v]!=0) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
					if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
				}
				else{
					if(grupo[u]==1){grupo[v]=2; v2++;}
					else{grupo[v]=1; v1++;}
					q.push(v);
				}
			}
		}

		if(n == v1+v2){break;}
		else{
			for (int i = 0; i < n; ++i) {
				if(grupo[i]==0){j=i; break;}
			}
		}

	}

	cout << v1 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	long long n, m, a, b, c ;
    cin >> n >> m ;
	vector< vector<long long> > gr(n);
	vector<long long> grupo(n,0);
	long long v1 = 0;
	long long v2 = 0;

    for (long long i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    for (long long i = 0; i < n; ++i) {
    	if(gr[i].empty()){grupo[i] = 3;}
    }

    long long j = 0 ;
    while(true){

		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<long long> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1++;
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				long long u = q.front(); q.pop() ;
				for(long long v : gr[u]) {
					if(grupo[v]==1 || grupo[v]==2) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
					}
					else if(grupo[v]==0){
						if(grupo[u]==1){grupo[v]=2; v2++;q.push(v);}
						else if(grupo[u]==2){grupo[v]=1; v1++;q.push(v);}
					}
				}
			}

			if(n == v1+v2){break;}
			else{
				int b =0;
				for (long long i = 0; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
					if(i==n-1){b=1;}
				}
				if(b ==1){break;}
			}

	}

	cout << v1 << endl ;
	for (long long i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (long long i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}
	cout << c ;
	return 0;
}


#include<iostream>
#include<iomanip>
#include<vector>
#include <math.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main() {

	// Inicializar variables
	int n, m, a, b ;
    cin >> n >> m ;
	vector< vector<int> > gr(n);
	vector<int> grupo(n,0);
	int v1 = 0;
	int v2 = 0;

    for (int i=0; i<m; i++) {
    	cin >> a >> b;
    	a--; b--;
    	gr[a].push_back(b);
    	gr[b].push_back(a);
    }

    for (int i = 0; i < n; ++i) {
    	if(gr[i].empty()){grupo[i] = 3;}
    }

    int j = 0 ;
    while(true){

		    // Recorrer grafo y contar numero de vertices por grupo
		    queue<int> q; q.push(j) ;
		    grupo[j] = 1 ; // Poner primer nodo en grupo 1
		    v1++;
			// Iteraciones sobre la cola
			while(!q.empty()) {
				// Sacar un elemento de la cola
				int u = q.front(); q.pop() ;
				for(int v : gr[u]) {
					if(grupo[v]!=0) { // Si nodo ha sido visitado. Chequear que tiene bien los colores
						if(grupo[u]==grupo[v]){cout << -1 << endl; return 0;}
					}
					else if(grupo[v]==1 || grupo[v]==2){
						if(grupo[u]==1){grupo[v]=2; v2++;}
						else{grupo[v]=1; v1++;}
						q.push(v);
					}
				}
			}

			if(n == v1+v2){break;}
			else{
				for (int i = 0; i < n; ++i) {
					if(grupo[i]==0){j=i; break;}
				}
			}

	}

	cout << v1 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 1){cout << i + 1 << " " ;}
	}
	cout << endl << v2 << endl ;
	for (int i = 0; i < grupo.size(); ++i) {
		if(grupo[i] == 2){cout << i + 1 << " " ;}
	}

	return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);set<int>a,b;map<int,char>det;
        int n,m;cin>>n>>m;vector<int> adj[n+1];
        int x,y;bool vis[n+1]={false};
        for(int i=0;i<m;i++)
        {cin>>x>>y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        for(int i=1;i<=n;i++)
        {
         if(vis[i]==true)
         {
             for(int j=0;j<adj[i].size();j++)
             {
                if(vis[adj[i][j]]==true && det[i]==det[adj[i][j]])
                 {cout<<-1;return 0;}
                else if(vis[adj[i][j]]==false)
                 {if(det[i]=='a'){det[adj[i][j]]='b';b.insert(adj[i][j]);}
                  else {det[adj[i][j]]='a';a.insert(adj[i][j]);}
                  vis[adj[i][j]]=true;
                 }
             }
         }
         else
         { int flag=0;
           for(int j=0;j<adj[i].size();j++)
           {if(vis[adj[i][j]]==true)
            {if(det[i]=='a'){det[i]='b';b.insert(i);}
             else {det[i]='a';a.insert(i);}flag=1;
             break;
            }
           }
           if(flag!=1){det[i]='b';b.insert(i);}
           vis[i]=true;
           i--;
         }

        }
        cout<<a.size()<<"\n";
         for(auto itr=a.begin();itr!=a.end();++itr)cout<<*itr<<" ";
         cout<<"\n";
         cout<<b.size()<<"\n";
         for(auto itr=b.begin();itr!=b.end();++itr)cout<<*itr<<" ";
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);set<int>a,b;map<int,char>det;
        int n,m;cin>>n>>m;vector<int> adj[n+1];queue<int>q;
        int x,y;bool vis[n+1]={false};
        for(int i=0;i<m;i++)
        {cin>>x>>y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        vis[1]=true;det[1]='a';a.insert(1);q.push(1);
        while(!q.empty())
        {
            int cur=q.front();
            for(int i=0;i<adj[cur].size();i++)
            {   if(vis[adj[cur][i]]==true && vis[cur]==true)
                {if(det[adj[cur][i]]==det[cur]){cout<<-1;return 0;}}
                if(vis[cur]==true && vis[adj[cur][i]]==false)
                {if(det[cur]=='a'){det[adj[cur][i]]='b';b.insert(adj[cur][i]);}
                 else {det[adj[cur][i]]='a';a.insert(adj[cur][i]);}
                 vis[adj[cur][i]]=true;q.push(adj[cur][i]);
                }
            }q.pop();
        }
        cout<<a.size()<<"\n";
        for(auto itr=a.begin();itr!=a.end();++itr)
         cout<<*itr<<" ";
        cout<<"\n";
        cout<<b.size()<<"\n";
        for(auto itr=b.begin();itr!=b.end();++itr)
         cout<<*itr<<" ";
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);set<int>a,b;map<int,char>det;
        int n,m;cin>>n>>m;vector<int> adj[n+1];queue<int>q;
        int x,y;bool vis[n+1]={false};
        for(int i=0;i<m;i++)
        {cin>>x>>y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        for(int k=1;k<=n;k++){if(vis[k]!=true){
        vis[1]=true;det[k]='a';a.insert(k);q.push(k);
        while(!q.empty())
        {
            int cur=q.front();
            for(int i=0;i<adj[cur].size();i++)
            {   if(vis[adj[cur][i]]==true && vis[cur]==true)
                {if(det[adj[cur][i]]==det[cur]){cout<<-1;return 0;}}
                if(vis[cur]==true && vis[adj[cur][i]]==false)
                {if(det[cur]=='a'){det[adj[cur][i]]='b';b.insert(adj[cur][i]);}
                 else {det[adj[cur][i]]='a';a.insert(adj[cur][i]);}
                 vis[adj[cur][i]]=true;q.push(adj[cur][i]);
                }
            }q.pop();
        }}
        }
        cout<<a.size()<<"\n";
        for(auto itr=a.begin();itr!=a.end();++itr)
         cout<<*itr<<" ";
        cout<<"\n";
        cout<<b.size()<<"\n";
        for(auto itr=b.begin();itr!=b.end();++itr)
         cout<<*itr<<" ";
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);set<int>a,b;map<int,char>det;
        int n,m;cin>>n>>m;vector<int> adj[n+1];
        int x,y;bool vis[n+1]={false};
        for(int i=0;i<m;i++)
        {cin>>x>>y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        for(int i=1;i<=n;i++)
        {
         if(vis[i]==true)
         {
             for(int j=0;j<adj[i].size();j++)
             {
                if(vis[adj[i][j]]==true && det[i]==det[adj[i][j]])
                 {cout<<-1;return 0;}
                else if(vis[adj[i][j]]==false)
                 {if(det[i]=='a'){det[adj[i][j]]='b';b.insert(adj[i][j]);}
                  else {det[adj[i][j]]='a';a.insert(adj[i][j]);}
                  vis[adj[i][j]]=true;
                 }
             }
         }
         else
         { int flag=0;
           for(int j=0;j<adj[i].size();j++)
           {if(vis[adj[i][j]]==true)
            {if(det[adj[i][j]]=='a'){det[i]='b';b.insert(i);}
             else {det[i]='a';a.insert(i);}flag=1;
             break;
            }
           }
           if(flag!=1){det[i]='b';b.insert(i);}
           vis[i]=true;
           i--;
         }
        }
        cout<<a.size()<<"\n";
         for(auto itr=a.begin();itr!=a.end();++itr)cout<<*itr<<" ";
         cout<<"\n";
         cout<<b.size()<<"\n";
         for(auto itr=b.begin();itr!=b.end();++itr)cout<<*itr<<" ";
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);set<int>a,b;map<int,char>det;
        int n,m;cin>>n>>m;vector<int> adj[n+1];queue<int>q;
        int x,y;bool vis[n+1]={false};
        for(int i=0;i<m;i++)
        {cin>>x>>y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        for(int k=1;k<=n;k++){if(vis[k]!=true){
        vis[k]=true;det[k]='a';a.insert(k);q.push(k);
        while(!q.empty())
        {
            int cur=q.front();
            for(int i=0;i<adj[cur].size();i++)
            {   if(vis[adj[cur][i]]==true && vis[cur]==true)
                {if(det[adj[cur][i]]==det[cur]){cout<<-1;return 0;}}
                if(vis[cur]==true && vis[adj[cur][i]]==false)
                {if(det[cur]=='a'){det[adj[cur][i]]='b';b.insert(adj[cur][i]);}
                 else {det[adj[cur][i]]='a';a.insert(adj[cur][i]);}
                 vis[adj[cur][i]]=true;q.push(adj[cur][i]);
                }
            }q.pop();
        }}
        }
        cout<<a.size()<<"\n";
        for(auto itr=a.begin();itr!=a.end();++itr)
         cout<<*itr<<" ";
        cout<<"\n";
        cout<<b.size()<<"\n";
        for(auto itr=b.begin();itr!=b.end();++itr)
         cout<<*itr<<" ";
    }


    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	ios_base::sync_with_stdio(false);
        cin.tie(NULL);set<int>a,b;map<int,char>det;
        int n,m;cin>>n>>m;vector<int> adj[n+1];queue<int>q;
        int x,y;bool vis[n+1]={false};
        for(int i=0;i<m;i++)
        {cin>>x>>y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        for(int k=1;k<=n;k++){if(vis[k]!=true){
        vis[1]=true;det[k]='a';a.insert(1);q.push(k);
        while(!q.empty())
        {
            int cur=q.front();
            for(int i=0;i<adj[cur].size();i++)
            {   if(vis[adj[cur][i]]==true && vis[cur]==true)
                {if(det[adj[cur][i]]==det[cur]){cout<<-1;return 0;}}
                if(vis[cur]==true && vis[adj[cur][i]]==false)
                {if(det[cur]=='a'){det[adj[cur][i]]='b';b.insert(adj[cur][i]);}
                 else {det[adj[cur][i]]='a';a.insert(adj[cur][i]);}
                 vis[adj[cur][i]]=true;q.push(adj[cur][i]);
                }
            }q.pop();
        }}
        }
        cout<<a.size()<<"\n";
        for(auto itr=a.begin();itr!=a.end();++itr)
         cout<<*itr<<" ";
        cout<<"\n";
        cout<<b.size()<<"\n";
        for(auto itr=b.begin();itr!=b.end();++itr)
         cout<<*itr<<" ";
    }


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v,u;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;
   E[edd].u=u;
   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        if(find(u)!=find(v))
        {fa[u]=v;add(u,v);add(v,u);a[u]++;a[v]++;}
        else{flag=1;}
        }

memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}
for(int i=0;i<m;i++)
{
    if(vis[E[i].v]==vis[E[i].u]){cout<<-1;return 0;}
}
cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v,u;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;
E[edd].u=u;
   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        add(u,v);add(v,u);
        }

memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}
for(int i=0;i<2*m;i++)
{if(vis[E[i].u]==vis[E[i].v])
    {
        cout<<-1;return 0;
    }
}
cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;

   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;int ux=find(u),uy=find(v);
        if(ux!=uy)
        {fa[ux]=uy;add(u,v);add(v,u);a[u]++;a[v]++;}
        else{flag=1;}
        }

if(flag){cout<<-1;
return 0;}
memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}

cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;

   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        if(find(u)!=find(v))
        {fa[u]=v;add(u,v);add(v,u);a[u]++;a[v]++;}
        else{flag=1;}
        }

if(flag){cout<<-1;
return 0;}
memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}

cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v,u;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;
E[edd].u=u;
   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        add(u,v);add(v,u);a[u]++;a[v]++;
        }

memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=0;i<2*m;i++)
{if(vis[E[i].u]==vis[E[i].v])
    { cout<<E[i].u<<" "<<E[i].v<<vis[E[i].v];;
        cout<<-1;return 0;
    }
}
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}

cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v,u;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;
E[edd].u=u;
   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        add(u,v);add(v,u);a[u]++;a[v]++;
        }

memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=0;i<2*m;i++)
{if(vis[E[i].u]==vis[E[i].v])
    {
        cout<<-1;return 0;
    }
}
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}

cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v,u;}E[200006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;
E[edd].u=u;
   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        add(u,v);add(v,u);a[u]++;a[v]++;
        }

memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=0;i<2*m;i++)
{if(vis[E[i].u]==vis[E[i].v])
    {
        cout<<-1;return 0;
    }
}
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}

cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <iostream>
#include <cstring>
using namespace std;
int n,m,fa[100006];
int find(int x)
{
    if(x!=fa[x]){fa[x]=find(fa[x]);}
    return fa[x];
}
struct k{int nxt,v;}E[100006];
int a[100005],p[100006],edd,ans1[100006],ans2[100006];
void init()
{memset(p,-1,sizeof(p));
    edd=0;
}
void add(int u,int v)
{  E[edd].v=v;
   E[edd].nxt= p[u];
    p[u]=edd++;
}
int vis[100006];
void dfs(int u,int step)
{  if(vis[u]!=-1)return ;
    vis[u]=step;
    for(int i=p[u];i!=-1;i=E[i].nxt)
    dfs(E[i].v,step^1);
}
int main()
{ cin>>n>>m;int flag=0;int d=0;init();
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=0;i<m;i++)
    {int u,v;cin>>u>>v;
        if(find(u)!=find(v))
        {fa[u]=v;add(u,v);add(v,u);a[u]++;a[v]++;}
        else{flag=1;}
        }

if(flag){cout<<-1;
return 0;}
memset(vis,-1,sizeof(vis));
for(int i=1;i<=n;i++)
{if(vis[i]==-1&&a[i])dfs(i,1);
}int a1=0,a2=0;
for(int i=1;i<=n;i++)
{if(vis[i]&&a[i]){ans1[a1++]=i;}
else if(a[i])ans2[a2++]=i;
}
cout<<a1<<endl;
for(int i=0;i<a1;i++)cout<<ans1[i]<<" ";cout<<endl;
cout<<a2<<endl;
for(int i=0;i<a2;i++)cout<<ans2[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
int a1[1000007];
int flag=1;
void dfs(vector<int> v[],int y)
{
    if(y==p)
    a1[y]=1;
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            if(a1[y]==1)
            a1[v[y][j]]=0;
            else
            a1[v[y][j]]=1;
            dfs(v,v[y][j]);
        }
                if(a1[y]==a1[v[y][j]])
                flag=0;
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    mem(a1,-1);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {p=i;dfs(v,i);}
    }
    c=c1=0;
    if(flag)
    {
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        c+=1;
        else if(a1[j]==1)
        c1+=1;
    }
    cout<<c<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        cout<<j<<" ";
    }
    cout<<endl<<c1<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==1)
        cout<<j<<" ";
    }
    }
    else
    cout<<-1;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
int a1[1000007];
int flag=1;
void dfs(vector<int> v[],int y,int j)
{
    a1[y]=j;
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j],1-a1[y]);
        }
        if(a1[y]==a1[v[y][j]])
            flag=0;
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    mem(a1,-1);
    for(int i=1;i<=n;i++)
    {
    if(a[i]==0)
    dfs(v,i,1);
    }
    c=c1=0;
    if(flag)
    {
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        c+=1;
        else if(a1[j]==1)
        c1+=1;
    }
    cout<<c<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        cout<<j<<" ";
    }
    cout<<endl<<c1<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==1)
        cout<<j<<" ";
    }
    }
    else
    cout<<-1;
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
int a1[1000007];
int flag=1;
void dfs(vector<int> v[],int y)
{
    if(y==1)
    a1[y]=1;
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            if(a1[y]==1)
            a1[v[y][j]]=0;
            else
            a1[v[y][j]]=1;
            dfs(v,v[y][j]);
        }
        if(a1[v[y][j]]!=-1)
            {
                if(a1[y]==a1[v[y][j]])
                flag=0;
            }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    mem(a1,-1);
    dfs(v,1);
    c=c1=0;
    if(flag)
    {
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        c+=1;
        else if(a1[j]==1)
        c1+=1;
    }
    cout<<c<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        cout<<j<<" ";
    }
    cout<<endl<<c1<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==1)
        cout<<j<<" ";
    }
    }
    else
    cout<<-1;
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
int flag=0;
#define make_pair mp
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
void dfs(vector<int> v[],int y)
{
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j]);
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    int a[n+1];
    mem(a,-1);
    vector<int> v[2];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(a[x]==-1&&a[y]==-1)
        {
            a[x]=1;
            a[y]=0;
            v[0].push_back(y);
            v[1].push_back(x);
        }
        else
        {
            if(a[x]==-1)
            {a[x]=abs(1-a[y]);
            v[a[x]].push_back(x);}
            else if(a[y]==-1)
            {a[y]=abs(1-a[x]);v[a[y]].push_back(y);}
            else
            return cout<<-1,0;
        }
    }
    cout<<v[0].size()<<endl;
    for(int j=0;j<v[0].size();j++)
    cout<<v[0][j]<<" ";
    cout<<endl<<v[1].size()<<endl;
    for(int j=0;j<v[1].size();j++)
    cout<<v[1][j]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
int a1[1000007];
int flag=1;
void dfs(vector<int> v[],int y)
{
    if(y==1)
    a1[y]=1;
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            if(a1[y]==1)
            a1[v[y][j]]=0;
            else
            a1[v[y][j]]=1;
            dfs(v,v[y][j]);
        }
                if(a1[y]==a1[v[y][j]])
                flag=0;
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    mem(a1,-1);
    dfs(v,1);
    c=c1=0;
    if(flag)
    {
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        c+=1;
        else if(a1[j]==1)
        c1+=1;
    }
    cout<<c<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        cout<<j<<" ";
    }
    cout<<endl<<c1<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==1)
        cout<<j<<" ";
    }
    }
    else
    cout<<-1;
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
int flag=0;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
void dfs(vector<int> v[],int y)
{
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j]);
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    int a[n+1];
    mem(a,-1);
    set<int> v[2];
    vector<pair<int,int>> v1;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(i==1)
        {
            a[x]=1;
            a[y]=0;
            v[0].insert(y);
            v[1].insert(x);
        }
        else if(a[x]==-1&&a[y]==-1)
        v1.push_back(make_pair(x,y));
        else
        {
            if(a[x]==-1)
            {a[x]=abs(1-a[y]);
            v[a[x]].insert(x);}
            else if(a[y]==-1)
            {a[y]=abs(1-a[x]);v[a[y]].insert(y);}
            else
            {
            if(a[x]==a[y])
            return cout<<-1,0;
            }
        }
    }
    for(int j=0;j<v1.size();j++)
    {
        if(a[v1[j].first]==-1&&a[v1[j].second]==-1)
        {
            v[0].insert(v1[j].first);
            v[0].insert(v1[j].second);
        }
        else if(a[v1[j].first]==-1)
        {
            v[abs(1-a[v1[j].second])].insert(v1[j].second);
        }
        else if(a[v1[j].second]==-1)
        v[abs(1-a[v1[j].first])].insert(v1[j].first);
        else
        {
            if(a[v1[j].first]==a[v1[j].second])
            return cout<<-1,0;
        }
    }
    cout<<v[0].size()<<endl;
auto it=v[0].begin();
for(;it!=v[0].end();it++)
cout<<*it<<" ";
    cout<<endl<<v[1].size()<<endl;
    it=v[1].begin();
    for(;it!=v[1].end();it++)
    cout<<*it<<" ";
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
int flag=0;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
void dfs(vector<int> v[],int y)
{
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j]);
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    int a[n+1];
    mem(a,-1);
    vector<int> v[2];
    vector<pair<int,int>> v1;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(i==1)
        {
            a[x]=1;
            a[y]=0;
            v[0].push_back(y);
            v[1].push_back(x);
        }
        else if(a[x]==-1&&a[y]==-1)
        v1.push_back(make_pair(x,y));
        else
        {
            if(a[x]==-1)
            {a[x]=abs(1-a[y]);
            v[a[x]].push_back(x);}
            else if(a[y]==-1)
            {a[y]=abs(1-a[x]);v[a[y]].push_back(y);}
            else
            {
            if(a[x]==a[y])
            return cout<<-1,0;
            }
        }
    }
    for(int j=0;j<v1.size();j++)
    {
        if(v1[j].first==-1&&v1[j].second==-1)
        {
            v[0].push_back(v1[j].first);
            v[0].push_back(v1[j].second);
        }
        else if(v1[j].first==-1)
        {
            v[abs(1-a[v1[j].second])].push_back(v1[j].second);
        }
        else if(v1[j].second==-1)
        v[abs(1-a[v1[j].first])].push_back(v1[j].first);
    }
    cout<<v[0].size()<<endl;
    for(int j=0;j<v[0].size();j++)
    cout<<v[0][j]<<" ";
    cout<<endl<<v[1].size()<<endl;
    for(int j=0;j<v[1].size();j++)
    cout<<v[1][j]<<" ";
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
int flag=0;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
void dfs(vector<int> v[],int y)
{
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j]);
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    int a[n+1];
    mem(a,-1);
    vector<int> v[2];
    vector<pair<int,int>> v1;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(i==1)
        {
            a[x]=1;
            a[y]=0;
            v[0].push_back(y);
            v[1].push_back(x);
        }
        else if(a[x]==-1&&a[y]==-1)
        v1.push_back(make_pair(x,y));
        else
        {
            if(a[x]==-1)
            {a[x]=abs(1-a[y]);
            v[a[x]].push_back(x);}
            else if(a[y]==-1)
            {a[y]=abs(1-a[x]);v[a[y]].push_back(y);}
            else
            {
            if(a[x]==a[y])
            return cout<<-1,0;
            }
        }
    }
    for(int j=0;j<v1.size();j++)
    {
        if(v1[j].first==-1&&v1[j].second==-1)
        {
            v[0].push_back(v1[j].first);
            v[0].push_back(v1[j].second);
        }
        else if(v1[j].first==-1)
        {
            v[abs(1-a[v1[j].second])].push_back(v1[j].second);
        }
        else if(v1[j].second==-1)
        v[abs(1-a[v1[j].first])].push_back(v1[j].first);
        else
        {
            if(a[v1[j].first]==a[v1[j].second])
            return cout<<-1,0;
        }
    }
    cout<<v[0].size()<<endl;
    for(int j=0;j<v[0].size();j++)
    cout<<v[0][j]<<" ";
    cout<<endl<<v[1].size()<<endl;
    for(int j=0;j<v[1].size();j++)
    cout<<v[1][j]<<" ";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
int a1[1000007];
int flag=1;
void dfs(vector<int> v[],int y)
{
    if(y==1)
    a1[y]=1;
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            if(a1[y]==1)
            a1[v[y][j]]=0;
            else
            a1[v[y][j]]=1;
            dfs(v,v[y][j]);
            if(a1[y]==a1[v[y][j]])
                flag=0;
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    mem(a1,-1);
    dfs(v,1);
    c=c1=0;
    if(flag)
    {
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        c+=1;
        else if(a1[j]==1)
        c1+=1;
    }
    cout<<c<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==0)
        cout<<j<<" ";
    }
    cout<<endl<<c1<<endl;
    for(int j=1;j<=n;j++)
    {
        if(a1[j]==1)
        cout<<j<<" ";
    }
    }
    else
    cout<<-1;
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
int flag=0;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
void dfs(vector<int> v[],int y)
{
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j]);
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    int a[n+1];
    mem(a,-1);
    vector<int> v[2];
    vector<pair<int,int>> v1;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(i==1)
        {
            a[x]=1;
            a[y]=0;
            v[0].push_back(y);
            v[1].push_back(x);
        }
        else if(a[x]==-1&&a[y]==-1)
        v1.push_back(make_pair(x,y));
        else
        {
            if(a[x]==-1)
            {a[x]=abs(1-a[y]);
            v[a[x]].push_back(x);}
            else if(a[y]==-1)
            {a[y]=abs(1-a[x]);v[a[y]].push_back(y);}
            else
            {
            if(a[x]==a[y])
            return cout<<-1,0;
            }
        }
    }
    for(int j=0;j<v1.size();j++)
    {
        if(a[v1[j].first]==-1&&a[v1[j].second]==-1)
        {
            v[0].push_back(v1[j].first);
            v[0].push_back(v1[j].second);
        }
        else if(a[v1[j].first]==-1)
        {
            v[abs(1-a[v1[j].second])].push_back(v1[j].second);
        }
        else if(a[v1[j].second]==-1)
        v[abs(1-a[v1[j].first])].push_back(v1[j].first);
        else
        {
            if(a[v1[j].first]==a[v1[j].second])
            return cout<<-1,0;
        }
    }
    cout<<v[0].size()<<endl;
    for(int j=0;j<v[0].size();j++)
    cout<<v[0][j]<<" ";
    cout<<endl<<v[1].size()<<endl;
    for(int j=0;j<v[1].size();j++)
    cout<<v[1][j]<<" ";
}


 #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mem(a,x) memset(a,x,sizeof(a))
int a[10000007];
long long int c1=0;
vector<int> v2;
lli p;
int flag=0;
typedef pair<lli,lli> ll;
bool cmp(string s,string p)
{
    if(s.length()==p.length())
    return s<p;
    return s.length()<p.length();
}
void dfs(vector<int> v[],int y)
{
    a[y]=1;
    for(int j=0;j<v[y].size();j++)
    {
        if(a[v[y][j]]==0)
        {
            dfs(v,v[y][j]);
        }
    }
}
main()
{
    lli k,x,y,m;x=-1;
    int n;
    int c=0;
    int c1=0;
    cin>>n>>m;
    int a[n+1];
    mem(a,-1);
    set<int> v[2];
    vector<pair<int,int>> v1;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(i==1)
        {
            a[x]=1;
            a[y]=0;
            v[0].insert(y);
            v[1].insert(x);
        }
        else if(a[x]==-1&&a[y]==-1)
        v1.push_back(make_pair(x,y));
        else
        {
            if(a[x]==-1)
            {a[x]=abs(1-a[y]);
            v[a[x]].insert(x);}
            else if(a[y]==-1)
            {a[y]=abs(1-a[x]);v[a[y]].insert(y);}
            else
            {
            if(a[x]==a[y])
            return cout<<-1,0;
            }
        }
    }
    for(int j=0;j<v1.size();j++)
    {
        if(a[v1[j].first]==-1&&a[v1[j].second]==-1)
        {
            v[0].insert(v1[j].first);
            v[1].insert(v1[j].second);
        }
        else if(a[v1[j].first]==-1)
        {
            v[abs(1-a[v1[j].second])].insert(v1[j].first);
        }
        else if(a[v1[j].second]==-1)
        v[abs(1-a[v1[j].first])].insert(v1[j].second);
        else
        {
            if(a[v1[j].first]==a[v1[j].second])
            return cout<<-1,0;
        }
    }
    cout<<v[0].size()<<endl;
auto it=v[0].begin();
for(;it!=v[0].end();it++)
cout<<*it<<" ";
    cout<<endl<<v[1].size()<<endl;
    it=v[1].begin();
    for(;it!=v[1].end();it++)
    cout<<*it<<" ";
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int n,m;
vector<int> v[100005];
int vis[200005];
vector<int> P;
vector<int> A;
int ans[200005];
bool can = true;

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]==1){
			if(ans[v[x][i]]==ans[x])
				can = false;
		}
		else{
			ans[v[x][i]] = 3-ans[x];
			dfs(vis[v[x][i]]);
		}
	}
	return;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,f;
		cin>>u>>f;
		v[u].push_back(f);
	}
	memset(vis,0,sizeof(vis));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[i]=1;
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(ans[i]==1)
			P.push_back(i);
		if(ans[i]==2)
			A.push_back(i);
	}
	if(!can)
		cout<<-1<<endl;
	cout<<P.size()<<endl;
	for(auto i:P)
		cout<<i<<" ";
	cout<<endl;
	cout<<A.size()<<endl;
	for(auto i:A)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int n,m;
vector<int> v[100005];
int vis[200005];
vector<int> P;
vector<int> A;
int ans[200005];
bool can = true;

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]==1){
			if(ans[v[x][i]]==ans[x])
				can = false;
		}
		else{
			ans[v[x][i]] = 3-ans[x];
			dfs(vis[v[x][i]]);
		}
	}
	return;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,f;
		cin>>u>>f;
		v[u].push_back(f);
	}
	memset(vis,0,sizeof(vis));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[i]=1;
			dfs(vis[i]);
		}
	}
	for(int i=1;i<=n;i++){
		if(ans[i]==1)
			P.push_back(i);
		if(ans[i]==2)
			A.push_back(i);
	}
	cout<<P.size()<<endl;
	for(auto i:P)
		cout<<i<<" ";
	cout<<endl;
	cout<<A.size()<<endl;
	for(auto i:A)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int n,m;
vector<int> v[100005];
int vis[200005];
vector<int> P;
vector<int> A;
int ans[200005];
bool can = true;

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]==1){
			if(ans[v[x][i]]==ans[x])
				can = false;
		}
		else{
			ans[v[x][i]] = 3-ans[x];
			dfs(v[x][i]);
		}
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,f;
		cin>>u>>f;
		v[u].push_back(f);
		v[f].push_back(u);
	}
	memset(vis,0,sizeof(vis));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[i]=1;
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(ans[i]==1)
			P.push_back(i);
		if(ans[i]==2)
			A.push_back(i);
	}
	if(!can)
		cout<<-1<<endl;
	else{
		cout<<P.size()<<endl;
		for(auto i:P)
			cout<<i<<" ";
		cout<<endl;
		cout<<A.size()<<endl;
		for(auto i:A)
			cout<<i<<" ";
		cout<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int n,m;
vector<int> v[100005];
int vis[200005];
vector<int> P;
vector<int> A;
int ans[200005];
bool can = true;

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]==1){
			if(ans[v[x][i]]==ans[x])
				can = false;
		}
		else{
			ans[v[x][i]] = 3-ans[x];
			dfs(v[x][i]);
		}
	}
	return;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,f;
		cin>>u>>f;
		v[u].push_back(f);
	}
	memset(vis,0,sizeof(vis));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[i]=1;
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(ans[i]==1)
			P.push_back(i);
		if(ans[i]==2)
			A.push_back(i);
	}
	if(!can)
		cout<<-1<<endl;
	cout<<P.size()<<endl;
	for(auto i:P)
		cout<<i<<" ";
	cout<<endl;
	cout<<A.size()<<endl;
	for(auto i:A)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int n,m;
vector<int> v[100005];
int vis[200005];
vector<int> P;
vector<int> A;
int ans[200005];
bool can = true;

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]==1){
			if(ans[v[x][i]]==ans[x])
				can = false;
		}
		else{
			ans[v[x][i]] = 3-ans[x];
			dfs(v[x][i]);
		}
	}
	return;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,f;
		cin>>u>>f;
		v[u].push_back(f);
	}
	memset(vis,0,sizeof(vis));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[i]=1;
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(ans[i]==1)
			P.push_back(i);
		if(ans[i]==2)
			A.push_back(i);
	}
	if(!can)
		cout<<-1<<endl;
	else{
	cout<<P.size()<<endl;
	for(auto i:P)
		cout<<i<<" ";
	cout<<endl;
	cout<<A.size()<<endl;
	for(auto i:A)
		cout<<i<<" ";
	cout<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int n,m;
vector<int> v[100005];
int vis[200005];
vector<int> P;
vector<int> A;
int ans[200005];
bool can = true;

void dfs(int x){
	vis[x]=1;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]==1){
			if(ans[v[x][i]]==ans[x])
				can = false;
		}
		else{
			ans[v[x][i]] = 3-ans[x];
			dfs(v[x][i]);
		}
	}
	return;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,f;
		cin>>u>>f;
		v[u].push_back(f);
		v[f].push_back(u);
	}
	memset(vis,0,sizeof(vis));
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			ans[i]=1;
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++){
		if(ans[i]==1)
			P.push_back(i);
		if(ans[i]==2)
			A.push_back(i);
	}
	if(!can)
		cout<<-1<<endl;
	else{
		cout<<P.size()<<endl;
		for(auto i:P)
			cout<<i<<" ";
		cout<<endl;
		cout<<A.size()<<endl;
		for(auto i:A)
			cout<<i<<" ";
		cout<<endl;
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
vector<pair<int, int>> p(100000);
bool a[100001] = { 0 }, b1[100001] = { 0 }, b2[100001] = { 0 };
bool k = 1;
list<int> s1, s2;

void dfs(int N, bool l) {
	a[N] = 1;
	if (l && !b2[N]) {
		if (!b1[N]) {
			s1.push_back(N);
			b1[N] = 1;
		}
	}
	else if (!b1[N]) {
		if (!b2[N]) {
			s2.push_back(N);
			b2[N] = 1;
		}
	}
	else k = 0;
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, !l);
		}
	}
	a[N] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
		p[i].first = t1;
		p[i].second = t2;
	}
	dfs(p[0].first,1);
	if (k) {
		cout << s1.size() << '\n';
		for (auto el : s1) cout << el << " ";
		cout << '\n' << s2.size() << '\n';
		for (auto el : s2) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
vector<pair<int, int>> p(100000);
bool a[100001] = { 0 };
bool k = 1;
set<int> s1, s2;

void dfs(int N, bool l) {
	a[N] = 1;
	if (l && s2.find(N) == s2.end()) s1.insert(N);
	else if (s1.find(N) == s1.end()) s2.insert(N);
	else k = 0;
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, !l);
		}
	}
	a[N] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
		p[i].first = t1;
		p[i].second = t2;
	}
	dfs(p[0].first,1);
	if (k) {
		cout << s1.size() << '\n';
		for (auto el : s1) cout << el << " ";
		cout << '\n' << s2.size() << '\n';
		for (auto el : s2) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
vector<pair<int, int>> p(100000);
bool a[100001] = { 0 }, b1[100001] = { 0 }, b2[100001] = { 0 };
bool k = 1;
list<int> s1, s2;

void dfs(int N, bool l) {
	a[N] = 1;
	if (l && !b2[N]) {
		s1.push_back(N);
		b2[N] = 1;
	}
	else if (!b1[N]) {
		s2.push_back(N);
		b1[N] = 1;
	}
	else k = 0;
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, !l);
		}
	}
	a[N] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
		p[i].first = t1;
		p[i].second = t2;
	}
	dfs(p[0].first,1);
	if (k) {
		cout << s1.size() << '\n';
		for (auto el : s1) cout << el << " ";
		cout << '\n' << s2.size() << '\n';
		for (auto el : s2) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
vector<pair<int, int>> p(100000);
bool a[100001] = { 0 }, b[100001] = { 0 };
bool k = 1;
set<int> s1, s2;

void dfs(int N, bool l) {
	a[N] = 1;
	b[N] = 1;
	if (l && !b[N]) s1.insert(N);
	else if (!b[N]) s2.insert(N);
	else k = 0;
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, !l);
		}
	}
	a[N] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
		p[i].first = t1;
		p[i].second = t2;
	}
	dfs(p[0].first,1);
	if (k) {
		cout << s1.size() << '\n';
		for (auto el : s1) cout << el << " ";
		cout << '\n' << s2.size() << '\n';
		for (auto el : s2) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
vector<pair<int, int>> p(100000);
bool a[100001] = { 0 }, b1[100001] = { 0 }, b2[100001] = { 0 };
bool k = 1;
list<int> s1, s2;

void dfs(int N, bool l) {
	a[N] = 1;
	if (l && !b2[N]) {
		s1.push_back(N);
		b1[N] = 1;
	}
	else if (!b1[N]) {
		s2.push_back(N);
		b2[N] = 1;
	}
	else k = 0;
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, !l);
		}
	}
	a[N] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
		p[i].first = t1;
		p[i].second = t2;
	}
	dfs(p[0].first,1);
	if (k) {
		cout << s1.size() << '\n';
		for (auto el : s1) cout << el << " ";
		cout << '\n' << s2.size() << '\n';
		for (auto el : s2) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
vector<pair<int, int>> p(100000);
bool a[100001] = { 0 }, b[100001] = { 0 };
bool k = 1;
set<int> s1, s2;

void dfs(int N, bool l) {
	a[N] = 1;
	if (l && !b[N]) s1.insert(N);
	else if (!b[N]) s2.insert(N);
	else k = 0;
	b[N] = 1;
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, !l);
		}
	}
	a[N] = 0;
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
		p[i].first = t1;
		p[i].second = t2;
	}
	dfs(p[0].first,1);
	if (k) {
		cout << s1.size() << '\n';
		for (auto el : s1) cout << el << " ";
		cout << '\n' << s2.size() << '\n';
		for (auto el : s2) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <sstream>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, m;
vector<list<int>> v(100001, list<int>());
bool a[100001] = { 0 };
bool k = 1;
vector<set<int>> p(2,set<int>());

void dfs(int N, int l) {
	a[N] = 1;
	p[l].insert(N);
	for (auto el : v[N]) {
		if (!a[el]) {
			dfs(el, 1 - l);
		}
		else if (p[1 - l].find(el) == p[1 - l].end()) k = 0;
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0,t1,t2; i < m; i++) {
		scanf("%d%d", &t1, &t2);
		v[t1].push_back(t2);
		v[t2].push_back(t1);
	}
	for (int i = 1; i <= n;i++) {
		if(!a[i] && v[i].size()) dfs(i, 1);
	}
	if (k) {
		cout << p[0].size() << '\n';
		for (auto el : p[0]) cout << el << " ";
		cout << '\n' << p[1].size() << '\n';
		for (auto el : p[1]) cout << el << " ";
	}
	else cout << -1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> a(100005),ans(2);
int clr[100005];
unordered_set<int> s;

bool bpt(int x){

	clr[x] = 1;
	ans[clr[x]].push_back(x);

	queue<int> q;
	q.push(x);

	while( q.size() ){

		int f = q.front();
		q.pop();

		for(int i=0 ; i<a[f].size() ; i++){
			int e = a[f][i] ;

			if( clr[e] == -1 ){
				clr[e] = 1 - clr[f] ;
				ans[clr[e]].push_back(e);
				q.push(e);
			}
			else if( clr[e] == -1 && clr[e] == clr[f] )
				return false;
		}
	}

	return true;

}

bool res(int n){

	for(int i=0 ; i<100005 ; i++)
		clr[i] = -1;

	for(auto i : s){

		if( clr[i] == -1 )
			if(bpt(i))
				continue;
			else
				return false;
	}

 	return true;
}

int main(){

	int n,m;
	cin>>n>>m;

	for(int i=0 ; i<m ; i++ ){

		int u,v;
		cin>>u>>v;

		s.insert(u);
		s.insert(v);

		a[u].push_back(v);
		a[v].push_back(u);

	}

	if(res(n)){
		cout<<ans[1].size()<<endl;
		for( auto i : ans[1] )
			cout<<i<<" ";

		cout<<endl<<ans[0].size()<<endl;
		for( auto i : ans[0] )
			cout<<i<<" ";
	}
	else
		cout<<-1;
}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> ans(2);
vector< vector< int >> a(100005);
int vis[100005];
int flag = true;

void res(int x){

	queue< pair<int,int> > q;
	q.push({x,0});
	int par = -1;

	while( q.size() ){

		int f = q.front().first , s = q.front().second ;
	        q.pop();

		if( vis[f] != -1){
			if( s == vis[f] )
				continue;
			else{
				flag = false;
				return ;
			}
		}
		s = ( s+1 ) % 2;
		vis[f] = s;
		ans[s].push_back(f);

		for(int i=0 ; i<a[f].size() ; i++){
			if(vis[a[f][i]] != -1){
				if( s == vis[f] ){
					flag = false;
					return ;
				}
			}

			if(vis[a[f][i]] == -1 && a[f][i] != par){
				q.push({a[f][i],s});
			}
		}

		par = f;
	}
}

int main(){

	for(int i=0 ; i<100005 ; i++ )
		vis[i] = -1 ;

	int n,m;
	cin>>n>>m;

	unordered_set<int> s;
	for(int i=0 ; i<m ; i++){

		int u,v;
		cin>>u>>v;

		a[u].push_back(v);
		a[v].push_back(u);
		s.insert(u);
		s.insert(v);
	}

	for(auto i : s)
		if(vis[i] == -1)
			res(i);

	if(flag){
		cout<<ans[1].size()<<endl;
		for(auto i : ans[1] )
			cout<<i<<' ';

		cout<<endl<<ans[0].size()<<endl;
		for(auto i : ans[0] )
			cout<<i<<' ';
	}else
		cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> ans(2),a(100005);
int vis[100005];
int flag = true;

void res(int x){

	queue< pair<int,int> > q;
	q.push({x,0});
	int par = -1;

	while( q.size() ){

		int f = q.front().first , s = q.front().second ;
	        q.pop();

		if( vis[f] != -1){
			if( s == vis[f] )
				continue;
			else{
				flag = false;
				return ;
			}
		}
		s = ( s+1 ) % 2;
		vis[f] = s;
		ans[s].push_back(f);

		for(int i=0 ; i<a[f].size() ; i++){
			if(vis[a[f][i]] != -1){
				if( s == vis[a[f][i]] ){
					flag = false;
					return ;
				}
			}

			if(vis[a[f][i]] == -1 && a[f][i] != par){
				q.push({a[f][i],s});
			}
		}

		par = f;
	}
}

int main(){

	for(int i=0 ; i<100005 ; i++ )
		vis[i] = -1 ;

	int n,m;
	cin>>n>>m;

	unordered_set<int> s;
	for(int i=0 ; i<m ; i++){

		int u,v;
		cin>>u>>v;

		a[u].push_back(v);
//		a[v].push_back(u);
		s.insert(u);
		s.insert(v);
	}

	for(auto i : s)
		if(vis[i] == -1)
			res(i);

	if(flag){
		cout<<ans[1].size()<<endl;
		for(auto i : ans[1] )
			cout<<i<<' ';

		cout<<endl<<ans[0].size()<<endl;
		for(auto i : ans[0] )
			cout<<i<<' ';
	}else
		cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> ans(2);
vector< vector< int >> a(100005);
int vis[100005];
int flag = true;

void res(int x){

	queue< pair<int,int> > q;
	q.push({x,0});
	int par = -1;

	while( q.size() ){

		int f = q.front().first , s = q.front().second ;
	        q.pop();

		if( vis[f] != -1){
			if( s == vis[f] )
				continue;
			else{
				flag = false;
				return ;
			}
		}
		s = ( s+1 ) % 2;
		vis[f] = s;
		ans[s].push_back(f);

		for(int i=0 ; i<a[f].size() ; i++){
			if(vis[a[f][i]] != -1){
				if( s == vis[a[f][i]] ){
					flag = false;
					return ;
				}
			}

			if(vis[a[f][i]] == -1 && a[f][i] != par){
				q.push({a[f][i],s});
			}
		}

		par = f;
	}
}

int main(){

	for(int i=0 ; i<100005 ; i++ )
		vis[i] = -1 ;

	int n,m;
	cin>>n>>m;

	unordered_set<int> s;
	for(int i=0 ; i<m ; i++){

		int u,v;
		cin>>u>>v;

		a[u].push_back(v);
		a[v].push_back(u);
		s.insert(u);
		s.insert(v);
	}

	for(auto i : s)
		if(vis[i] == -1)
			res(i);

	if(flag){
		cout<<ans[1].size()<<endl;
		for(auto i : ans[1] )
			cout<<i<<' ';

		cout<<endl<<ans[0].size()<<endl;
		for(auto i : ans[0] )
			cout<<i<<' ';
	}else
		cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> ans(2);
vector< vector< int >> a(100005);
int vis[100005];
int flag = true;

void res(int x){

	queue< pair<int,int> > q;
	q.push({x,0});
	int par = -1;

	while( q.size() ){

		int f = q.front().first , s = q.front().second ;
	        q.pop();

		if( vis[f] != -1){
			if( s == vis[f] )
				continue;
			else{
				flag = false;
				return ;
			}
		}
		s = ( s+1 ) % 2;
		vis[f] = s;
		ans[s].push_back(f);

		for(int i=0 ; i<a[x].size() ; i++){
			if(vis[a[x][i]] == -1 && a[x][i] != par){
				q.push({a[x][i],s});
			}
		}

		par = x;
	}
}

int main(){

	for(int i=0 ; i<100005 ; i++ )
		vis[i] = -1 ;

	int n,m;
	cin>>n>>m;

	unordered_set<int> s;
	for(int i=0 ; i<m ; i++){

		int u,v;
		cin>>u>>v;

		a[u].push_back(v);
		a[v].push_back(u);
		s.insert(u);
		s.insert(v);
	}

	for(auto i : s)
		if(vis[i] == -1)
			res(i);

	if(flag){
		cout<<ans[1].size()<<endl;
		for(auto i : ans[1] )
			cout<<i<<' ';

		cout<<endl<<ans[0].size()<<endl;
		for(auto i : ans[0] )
			cout<<i<<' ';
	}else
		cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> ans(2),a(100005);
int vis[100005];
int flag = true;

void res(int x){

	queue< pair<int,int> > q;
	q.push({x,0});
	int par = -1;

	while( q.size() ){

		int f = q.front().first , s = q.front().second ;
	        q.pop();

		if( vis[f] != -1){
			if( s == vis[f] )
				continue;
			else{
				flag = false;
				return ;
			}
		}
		s = ( s+1 ) % 2;
		vis[f] = s;
		ans[s].push_back(f);

		for(int i=0 ; i<a[f].size() ; i++){
			if(vis[a[f][i]] != -1){
				if( s == vis[a[f][i]] ){
					flag = false;
					return ;
				}
			}

			if(vis[a[f][i]] == -1 && a[f][i] != par){
				q.push({a[f][i],s});
			}
		}

		par = f;
	}
}

int main(){

	for(int i=0 ; i<100005 ; i++ )
		vis[i] = -1 ;

	int n,m;
	cin>>n>>m;

	unordered_set<int> s;
	for(int i=0 ; i<m ; i++){

		int u,v;
		cin>>u>>v;

		a[u].push_back(v);
	//		a[v].push_back(u);
		s.insert(u);
		s.insert(v);
	}

	for(auto i : s)
		if(vis[i] == -1)
			res(i);

	if(flag){
		cout<<ans[1].size()<<endl;
		for(auto i : ans[1] )
			cout<<i<<' ';

		cout<<endl<<ans[0].size()<<endl;
		for(auto i : ans[0] )
			cout<<i<<' ';
	}else
		cout<<-1;

}


#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> a(100005),ans(2);
int clr[100005];
unordered_set<int> s;

bool bpt(int x){

	clr[x] = 1;
	ans[clr[x]].push_back(x);

	queue<int> q;
	q.push(x);

	while( q.size() ){

		int f = q.front();
		q.pop();

		for(int i=0 ; i<a[f].size() ; i++){
			int e = a[f][i] ;

			if( clr[e] == -1 ){
				clr[e] = 1 - clr[f] ;
				ans[clr[e]].push_back(e);
				q.push(e);
			}
			else if( clr[e] == clr[f] )
				return false;
		}
	}

	return true;

}

bool res(){

	for(int i=0 ; i<100005 ; i++)
		clr[i] = -1;

	for(auto i : s){

		if( clr[i] == -1 )
			if(bpt(i))
				continue;
			else
				return false;
	}

 	return true;
}

int main(){

	int n,m;
	cin>>n>>m;

	for(int i=0 ; i<m ; i++ ){

		int u,v;
		cin>>u>>v;

		s.insert(u);
		s.insert(v);

		a[u].push_back(v);
		a[v].push_back(u);

	}

	if(res()){
		cout<<ans[1].size()<<endl;
		for( auto i : ans[1] )
			cout<<i<<" ";

		cout<<endl<<ans[0].size()<<endl;
		for( auto i : ans[0] )
			cout<<i<<" ";
	}
	else
		cout<<-1;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[100001];
int cnt1[100001],cnt21[100001],cnt22[100001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);

	}
	queue< pair<int,int> >q;

	q.push(mp(1,0));
	visited[1]++;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		if(y==1){
			if(cnt22[x]==0){			s2.pb(x);cnt22[x]++;
		}
		}
		else{
			if(cnt21[x]==0){
				s1.pb(x);
				cnt21[x]++;
			}
		}
		visited[x]++;
		q.pop();
		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));

				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));

				}
			}

		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[1000001];
int cnt1[1000001],cnt21[1000001],cnt22[1000001];
vector< vector<int> >g(100000+1);
vector<int>s1,s2;
void dfs(int x1)
{
		stack< pair<int,int> >q;
	int i;
	q.push(mp(x1,0));
	visited[x1]++;
	while(!q.empty())
	{
		int x=q.top().first;
		int y=q.top().second;
		visited[x]++;
		q.pop();
		if(y==1){
			if(cnt22[x]==0){			s1.pb(x);cnt22[x]++;
		}
		}
		else{
			if(cnt21[x]==0){
				s2.pb(x);
				cnt21[x]++;
			}
		}

		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				int k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));

				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				int k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));

				}
			}

		}
	}
}
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;

	int x1;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		 x1=u;

	}

	for(i=1;i<=n;i++)
	{
		if(visited[i]==0)
		{
			dfs(i);
		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[1000001];
int cnt1[1000001],cnt21[1000001],cnt22[1000001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	int x1;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		 x1=u;

	}
	queue< pair<int,int> >q;

	q.push(mp(x1,0));
	visited[x1]++;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		visited[x]++;
		q.pop();
		if(y==1){
			if(cnt22[x]==0){			s2.pb(x);cnt22[x]++;
		}
		}
		else{
			if(cnt21[x]==0){
				s1.pb(x);
				cnt21[x]++;
			}
		}

		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));

				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));

				}
			}

		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[1000001];
int cnt1[1000001],cnt21[1000001],cnt22[1000001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	int x1;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		 x1=u;

	}
	stack< pair<int,int> >q;

	q.push(mp(x1,0));
	visited[x1]++;
	while(!q.empty())
	{
		int x=q.top().first;
		int y=q.top().second;
		visited[x]++;
		q.pop();
		if(y==1){
			if(cnt22[x]==0){			s1.pb(x);cnt22[x]++;
		}
		}
		else{
			if(cnt21[x]==0){
				s2.pb(x);
				cnt21[x]++;
			}
		}

		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));

				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));

				}
			}

		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[100001];
int cnt1[100001],cnt21[100001],cnt22[100001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	int x1;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		 x1=v;

	}
	queue< pair<int,int> >q;

	q.push(mp(x1,0));
	visited[x1]++;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		visited[x]++;
		q.pop();
		if(y==1){
			if(cnt22[x]==0){			s2.pb(x);cnt22[x]++;
		}
		}
		else{
			if(cnt21[x]==0){
				s1.pb(x);
				cnt21[x]++;
			}
		}

		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));

				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));

				}
			}

		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[100001];
int cnt1[100001],cnt2[100001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);

	}
	queue< pair<int,int> >q;
	s1.pb(1);
	q.push(mp(1,0));
	visited[1]++;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		visited[x]++;
		q.pop();
		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));
					s2.pb(k);
				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));
					s1.pb(k);
				}
			}

		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[100001];
int cnt1[100001],cnt21[100001],cnt22[100001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	int x1;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		 x1=v;

	}
	queue< pair<int,int> >q;

	q.push(mp(x1,0));
	visited[x1]++;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		visited[x]++;
		q.pop();


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
int visited[100001];
int cnt1[100001],cnt21[100001],cnt22[100001];
int main() {

	int n,m,i,j,u,v,k;
	cin>>n>>m;
	vector< vector<int> >g(n+1);
		vector<int>s1,s2;
	int x1;
	while(m--)
	{
		cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
		 x1=u;

	}
	queue< pair<int,int> >q;

	q.push(mp(x1,0));
	visited[x1]++;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		visited[x]++;
		q.pop();
		if(y==1){
			if(cnt22[x]==0){			s2.pb(x);cnt22[x]++;
		}
		}
		else{
			if(cnt21[x]==0){
				s1.pb(x);
				cnt21[x]++;
			}
		}

		if(y==0){
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,1));

				}
			}
		}
		else
		{
			for(i=0;i<g[x].size();i++)
			{
				k=g[x][i];
				if(visited[k]==0){
					q.push(mp(k,0));

				}
			}

		}
	}
		int m1=s1.size(),c=0;
		int m2=s2.size();
		for(i=0;i<m1;i++)
			cnt1[s1[i]]++;
		for(i=0;i<m2;i++)
			{
				if(cnt1[s2[i]]!=0)
					c++;
			}
		if(c!=0)
		{
			cout<<-1;
			return 0;
		}
		cout<<m1<<endl;
		for(i=0;i<m1;i++)
			cout<<s1[i]<<' ';
		cout<<endl;
		cout<<m2<<endl;
		for(i=0;i<m2;i++)
			cout<<s2[i]<<' ';

	return 0;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(a[x]==a[g[x][i]])
			cycle=true;
		if(!vis[g[x][i]])
		{
			if(a[x]==1 and !a[g[x][i]]) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2 and !a[g[x][i]]) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}

	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    memset(vis,false,sizeof vis);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	if(cycle)
	    	{
	    		cout<<"-1"<<endl;
	    		return 0;
	    	}
	    	if(!vis[i] and g[i].size()>0)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(cycle) return;
		if(!vis[g[x][i]])
		{
			if(a[x]==1) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}
		if(a[x]==a[g[x][i]])
		{
			cycle=true;
			return;
		}
	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    memset(vis,false,sizeof vis);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	cycle=false;
	    	if(!vis[i] and g[i].size()>0)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    if(v1.size()==0 or v2.size()==0 )
	    {
	    	cout<<"-1";
	    	return 0;
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(cycle) return;
		if(a[x]==a[g[x][i]])
		{
			cycle=true;
			return;
		}
		if(!vis[g[x][i]])
		{
			if(a[x]==1) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}

	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    memset(vis,false,sizeof vis);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	cycle=false;
	    	if(!vis[i] and g[i].size()>0)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    if(v1.size()==0 or v2.size()==0 )
	    {
	    	cout<<"-1";
	    	return 0;
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(cycle) return;
		if(!vis[g[x][i]])
		{
			if(a[x]==1) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}
		if(a[x]==a[g[x][i]])
		{
			cycle=true;
			return;
		}
	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	cycle=false;
	    	if(!vis[i] and g[i].size()>0)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    if(v1.size()==0 or v2.size()==0 )
	    {
	    	cout<<"-1";
	    	return 0;
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(a[x]==a[g[x][i]])
			cycle=true;
		if(!vis[g[x][i]])
		{
			if(a[x]==1 and !a[g[x][i]]) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2 and !a[g[x][i]]) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}

	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    memset(vis,false,sizeof vis);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	cycle=false;
	    	if(!vis[i] and g[i].size()>0)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    if(v1.size()==0 or v2.size()==0 )
	    {
	    	cout<<"-1";
	    	return 0;
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(cycle) return;
		if(a[x]==a[g[x][i]])
		{
			cycle=true;
			return;
		}
		if(!vis[g[x][i]] )
		{
			if(a[x]==1 and !a[g[x][i]]) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2 and !a[g[x][i]]) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}

	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    memset(vis,false,sizeof vis);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	cycle=false;
	    	if(!vis[i] and g[i].size()>0)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    if(v1.size()==0 or v2.size()==0 )
	    {
	    	cout<<"-1";
	    	return 0;
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
using namespace std;
bool cycle=false;
vector<int> c;

void dfs(int x,vector<int> g[],bool vis[],int a[])
{
	vis[x]=true;
	for(int i=0;i<g[x].size();i++)
	{
		if(a[x]==a[g[x][i]])
			cycle=true;
		if(!vis[g[x][i]])
		{
			if(a[x]==1 and !a[g[x][i]]) a[g[x][i]]=2,c.push_back(g[x][i]);
			else if(a[x]==2 and !a[g[x][i]]) a[g[x][i]]=1,c.push_back(g[x][i]);
			dfs(g[x][i],g,vis,a);
		}

	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    IOS;
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n,m;
	    cin>>n>>m;
	    vector<int> g[n+1];
	    bool vis[n+1];
	    int a[n+1];
	    memset(a,0,sizeof a);
	    memset(vis,false,sizeof vis);
	    for(int i=0;i<m;i++)
	    {
	    	int u,v;
	    	cin>>u>>v;
	    	g[u].push_back(v);
	    	g[v].push_back(u);
	    }
	    // 1-RED 2-BLUE
	    vector<int> v1,v2;
	    for(int i=1;i<n+1;i++)
	    {
	    	if(!vis[i] and g[i].size()>0 and !cycle)
	    	{
	    		a[i]=1;
	    		c.push_back(i);
	    		dfs(i,g,vis,a);
	    		if(!cycle)
	    		{
	    			for(int i=0;i<c.size();i++)
	    			{
	    				if(a[c[i]]==1) v1.push_back(c[i]);
	    				else v2.push_back(c[i]);
	    			}
	    		}
	    	}
	    	c.clear();
	    }
	    if(v1.size()==0 or v2.size()==0 )
	    {
	    	cout<<"-1";
	    	return 0;
	    }
	    cout<<v1.size()<<endl;
	    for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	    cout<<endl<<v2.size()<<endl;
		for(int i=0;i<v2.size();i++) cout<<v2[i]<<" ";
	}
}