#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2014;

class TwoSAT{
private:
	int n;
	vector <int> G[MAXN*2];
	bool mark[MAXN*2];
	int S[MAXN*2], c;

	bool dfs(int x)
	{
		if (mark[x^1]) return false;
		if (mark[x]) return true;
		mark[x] = true;
		S[c++] = x;
		for (int i = 0; i<G[x].size(); i++){
			if (!dfs(G[x][i])) return false;
		}
		return true;
	}
public:
	void init(int n)
	{
		this->n = n;
		for (int i = 0; i<n*2; i++) G[i].clear();
		memset(mark, 0, sizeof(mark));
	}

/*
	Add clause : x==xval or y==yval
	xval and yval are bool
*/
	void add_clause(int x, int xval, int y, int yval)
	{
		x = x*2+xval;
		y = y*2+yval;
		G[x^1].push_back(y);
		G[y^1].push_back(x);
	}

	bool solve()
	{
		for (int i = 0; i<n*2; i+=2){
			if (!mark[i] && !mark[i+1]){
				c = 0;
				if (!dfs(i)){
					while (c>0) mark[S[--c]] = false;
					if (!dfs(i+1)) return false;
				}
			}
		}
		return true;
	}

	void getSolution(bool sol[])
	{
		for (int i = 0; i<n*2; i++) sol[i] = mark[i];
	}
};

int n, m;
bool mat[MAXN][MAXN];
TwoSAT wiseMan;
vector <int> p1, p2;

bool check(vector <int> p)
{
	for (int i = 0; i<p.size(); i++)
		for (int j = i+1; j<p.size(); j++)
			if (!mat[p[i]][p[j]]) return 0;
	return 1;
}

int main()
{
	while (scanf("%d%d", &n, &m)==2){
		memset(mat, 0, sizeof(mat));
		p1.clear(); p2.clear();
		p1.push_back(1);
		p2.push_back(2);
		for (int i = 1; i<=m; i++){
			int a, b;
			scanf("%d%d", &a, &b);
			mat[a][b] =	mat[b][a] = 1;
		}
		vector <int> neighboorsOfWinter;
		vector <int> neighboorsOfKing;
		vector <int> rest;
		for (int i = 3; i<=n; i++){
			if (mat[1][i]) neighboorsOfWinter.push_back(i);
			else if (mat[2][i]) neighboorsOfKing.push_back(i);
			else rest.push_back(i);
		}
		if (!check(rest)){
			cout<<"impossible"<<endl;
			continue;
		}

		bool res[MAXN*2] = {0};
		int existenceOfSolution;
		int size1, size2;
		size1 = neighboorsOfWinter.size();
		size2 = neighboorsOfKing.size();

		wiseMan.init(size1+size2);
		for (int i = 0; i<size1+size2; i++){
			int x;
			if (i<size1) x = neighboorsOfWinter[i];
			else x = neighboorsOfKing[i-size1];
			int flag = 1;
			for (int j = 0; j<rest.size(); j++){
				if (!mat[x][rest[j]]){
					flag = 0;
					break;
				}
			}
			if (!flag) wiseMan.add_clause(i,1,i,1);
			else wiseMan.add_clause(i,0,i,1);
			if (i<size1){
				for (int j = i+1; j<size1; j++){
					int y = neighboorsOfWinter[j];
					if (!mat[x][y]){
						wiseMan.add_clause(i,0,j,0);
						wiseMan.add_clause(i,1,j,1);
					}
				}
				for (int j = size1; j<size1+size2; j++){
					int y = neighboorsOfKing[j-size1];
					if (!mat[x][y]) wiseMan.add_clause(i,1,j,1);
				}
			}
			else{
				for (int j = i+1; j<size1+size2; j++){
					int y = neighboorsOfKing[j-size1];
					if (!mat[x][y]){
						wiseMan.add_clause(i,0,j,0);
						wiseMan.add_clause(i,1,j,1);
					}
				}
			}			
		}

		existenceOfSolution = wiseMan.solve();
		if (!existenceOfSolution){
			cout<<"impossible"<<endl;
			continue;
		}
		memset(res, 0, sizeof(res));
		wiseMan.getSolution(res);

		for (int i = 0; i<size1; i++){
			if (res[i*2]) rest.push_back(neighboorsOfWinter[i]);
			else if (res[i*2+1]) p1.push_back(neighboorsOfWinter[i]);
			else assert(1+1!=2);
		}
		for (int i = size1; i<size1+size2; i++){
			if (res[i*2]) rest.push_back(neighboorsOfKing[i-size1]);
			else if (res[i*2+1]) p2.push_back(neighboorsOfKing[i-size1]);
			else assert(1+1!=2);
		}

		sort(p1.begin(), p1.end());
		sort(p2.begin(), p2.end());
		for (int i = 0; i<p1.size()-1; i++) cout<<p1[i]<<" ";
		cout<<p1[p1.size()-1]<<endl;
		for (int i = 0; i<p2.size()-1; i++) cout<<p2[i]<<" ";
		cout<<p2[p2.size()-1]<<endl;
	}
}
