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

const MAXN=1000;
      MAXM=2000;
var N,M,N_1,N_2,i:integer;
    the_part:array[1..MAXN] of byte;
    pairs:array[1..MAXM,1..2] of integer;
    result:boolean;
    changed:boolean;

BEGIN
  read(N);
  read(M);
  for i:=1 to M do begin
    read(pairs[i,1],pairs[i,2]);
  end;
  for i:=1 to N do the_part[i]:=0;
  N_1:=0; N_2:=0;
  if M=0 then begin
    N_1:=N div 2;
    for i:=1 to N_1 do the_part[i]:=1;
    for i:=N_1+1 to N do the_part[i]:=2;
  end else begin
    while N_1+N_2<N do begin
      i:=1;
      while the_part[i]<>0 do i:=i+1;
      the_part[i]:=1;
      N_1:=N_1+1;
      repeat
        changed:=false;
        for i:=1 to M do begin
          if (the_part[pairs[i,1]]=0) xor (the_part[pairs[i,2]]=0) then begin
            {в точностi один кiнець ребра непризначений}
            if the_part[pairs[i,1]]=0 then begin
              the_part[pairs[i,1]]:=3-the_part[pairs[i,2]];
              if the_part[pairs[i,1]]=1 then N_1:=N_1+1 else N_2:=N_2+1;
              changed:=true;
            end else begin
              the_part[pairs[i,2]]:=3-the_part[pairs[i,1]];
              if the_part[pairs[i,2]]=1 then N_1:=N_1+1 else N_2:=N_2+1;
              changed:=true;
            end
          end;
        end
      until not changed;
    end;
  end;
  result:=true;
  for i:=1 to M do begin
    if the_part[pairs[i,1]]=the_part[pairs[i,2]] then result:=false;
  end;
  if result then begin
    writeln(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.
