{note. special case M=0 should not lead to answer "cannot divide"}

const MAXN=10000;

type PList=^TList;
     TList=record
             v:integer;
             next:PList;
           end;

var N,M,N_1,i,v,u:integer;
    the_part:array[1..MAXN] of byte;
    list_hdp:array[1..MAXN] of PList;
    result:boolean;
    p:PList;

function CanSplit(the_v:integer;the_v_part:byte):boolean;
var p:PList;
Begin
  the_part[the_v]:=the_v_part;
  p:=list_hdp[the_v];
  while p<>nil do begin
    if the_part[p^.v]=0 then begin
      if not CanSplit(p^.v,3-the_v_part) then begin
        CanSplit:=false; exit;
      end
    end else
      if the_part[p^.v]=the_part[the_v] then begin
        CanSplit:=false; exit;
      end;
    p:=p^.next;
  end;
  CanSplit:=true;
End;

BEGIN
  readln(N);
  for i:=1 to N do list_hdp[i]:=nil;
  readln(M);
  for i:=1 to M do begin
    readln(v,u);
    new(p);
    p^.v:=u;
    p^.next:=list_hdp[v];
    list_hdp[v]:=p;
    new(p);
    p^.v:=v;
    p^.next:=list_hdp[u];
    list_hdp[u]:=p;
  end;
  for i:=1 to N do the_part[i]:=0;
  result:=true;
  for i:=1 to N do
    if the_part[i]=0 then
      if not CanSplit(i,i mod 2 + 1) then begin
{i mod 2 +1 for not need special check of M=0 only}
        result:=false; break;
      end;
  if result then begin
    N_1:=0;
    for i:=1 to N do
      if the_part[i]=1 then
        N_1:=N_1+1;
{    writeln(fv,N_1);}
    for i:=1 to N do
      if the_part[i]=1 then
        write(i,' ');
    writeln;
    for i:=1 to N do
      if the_part[i]=2 then
        write(i,' ');
    writeln;
  end else
    writeln('0');
END.
