{$O-,Q+,R+,S+}
program synonym_gen_MiXa;

uses
    SysUtils;

Var
    l, yes, genType, ones: integer;
    a, b: array of integer;
    s: string;

Function GetRandomChar(): integer;
Begin
	if (random(100) < ones) then
    	Result := 1
    else
    	Result := 0;
End;

Procedure Swap(q, w: integer);
Var
	i, j: integer;
Begin
	b := copy(a, 0, length(a));
	For i := q to w do Begin
        j := w - (i - q);
        a[i] := b[j];
    End;
End;

Procedure Shuffle();
Var
    i, j, q, w, c: integer;
Begin
	For i := 1 to l*2 do Begin
    	q := random(l-1);
        w := q + random(l-q);
        c := 0;
        For j := q to w do Begin
			c := c + a[j];
        End;
        if c mod 2 = 0 then Begin
        	Swap(q, w);
        End;
    End;
End;

Procedure Save();
Var
    i,j: integer;
Begin
    randseed := StrToInt(ParamStr(1));
    l := StrToInt(ParamStr(2));
    yes := StrToInt(ParamStr(3));
    genType := StrToInt(ParamStr(4));
    ones := StrToInt(ParamStr(5));

    if genType < 2 then Begin
    	setLength(a, l);
        For i := 0 to l-1 do Begin
        	a[i] := GetRandomChar();
            write(a[i]);
        End;
        writeln;
        if (yes = 1) then Begin
        	Shuffle();
	        For i := 0 to l-1 do Begin
        	    write(a[i]);
    	    End;
	        writeln;
        End else Begin
		    if genType = 0 then Begin
		        For i := 0 to l-1 do Begin
    	    		a[i] := GetRandomChar();
        		    write(a[i]);
    	    	End;
		        writeln;
            End else Begin
	        	For i := 1 to l-1 do Begin
					if (a[i] + a[i-1] = 1) then Begin
                    	a[i] := 1 - a[i];
                    	a[i-1] := 1 - a[i-1];
                        break;
                    End;
                End;
	        	Shuffle();
	        	For i := 0 to l-1 do Begin
        		    write(a[i]);
    		    End;
		        writeln;
            End;
        End;
    End;
    if genType = 2 then Begin
		write(0);
        For i := 2 to l do
        	write(1);
        writeln;
		write(110);
        For i := 4 to l do
        	write(1);
        writeln;
    End;
    if genType = 3 then Begin
        For i := 2 to l do
        	write(1);
		write(0);
        writeln;
        For i := 4 to l do
        	write(1);
		write('011');
        writeln;
    End;
    if genType = 4 then Begin
		write('010');
        For i := 4 to l do
        	write(1);
        writeln;
		write(1010);
        For i := 5 to l do
        	write(1);
        writeln;
    End;
    if genType = 5 then Begin
        For i := 4 to l do
        	write(1);
		write('010');
        writeln;
        For i := 5 to l do
        	write(1);
		write('0101');
        writeln;
    End;
    if genType = 6 then Begin
        For i := 1 to l div 2 do
        	write(1);
        For i := l div 2 + 1 to l do
        	write(0);
        writeln;
        For i := l div 2 + 1 to l do
        	write(0);
        For i := 1 to l div 2 do
        	write(1);
        writeln;
    End;
    if genType = 7 then Begin
        For i := 1 to l div 2 do
        	write(0);
        For i := l div 2 + 1 to l do
        	write(1);
        writeln;
        For i := l div 2 + 1 to l do
        	write(1);
        For i := 1 to l div 2 do
        	write(0);
        writeln;
    End;
    if genType = 8 then Begin
        For i := 1 to l - 2 do
        	write(0);
        write(11);
        writeln;
        write(11);
        For i := 1 to l - 2 do
        	write(0);
        writeln;
    End;
    if genType = 9 then Begin
        write(11);
        For i := 1 to l - 2 do
        	write(0);
        writeln;
        For i := 1 to l - 2 do
        	write(0);
        write(11);
        writeln;
    End;
    if genType = 10 then Begin
        For i := 1 to l div 2 do
        	write('01');
        writeln;
        For i := 1 to l div 2 do
        	write('10');
        writeln;
    End;
    if genType = 11 then Begin
        For i := 1 to l div 2 do
        	write(0);
        For i := l div 2 + 1 to l do
        	write(1);
        writeln;
        For i := l div 2 + 1 to l do
        	write(1);
        For i := 1 to l div 2 do
        	write(0);
        writeln;
    End;
    if genType = 12 then Begin
    	setLength(a, l);
    	write('0101');
    	
        For i := 0 to l div 2 do Begin
        	s := s + IntToStr(GetRandomChar());
        End;
        write(s);
        write('0101');
        write(s);
        writeln;
        write('1010');
        write(s);
        write('1010');
        write(s);
        writeln;
    End;
    if genType = 13 then Begin
        For i := 1 to l div 2000 do begin
        	For j := 1 to 1000 do begin
        	  write(1);
        	End;
        	For j := 1 to 1000 do begin
        	  write(0);
        	End;
        End;
        writeln;
        For i := 1 to l div 2000 do begin
        	For j := 1 to 1000 do begin
        	  write(0);
        	End;
        	For j := 1 to 1000 do begin
        	  write(1);
        	End;
        End;
        writeln;
    End;
End;

begin
    Save();
end.