{$O-,Q+,R+}
uses SysUtils;

var n, p1, p2, k, l, i, v1, v2, x : integer;
    s, t : string;

function sxor (const x, y : string) : string;
var i : integer;
begin
  setlength (Result, n);
  for i := 1 to n do Result [i] := chr (ord (x[i] <> y[i]) + 48);
end;

begin
  n := strtoint (paramstr (1));
  p1 := strtoint (paramstr (2));
  p2 := strtoint (paramstr (3));
  k := strtoint (paramstr (4));
  l := strtoint (paramstr (5));
  v1 := strtoint (paramstr (6));
  v2 := strtoint (paramstr (7));
  randseed := strtoint (paramstr (8));
  if k = 0 then k := random (n) + 1;
  if l = 0 then l := random (n) + 1;
  setlength (s, n);
  for i := 1 to n do s[i] := chr (ord (random (p2) < p1) + 48);
  t := sxor (copy (s, l, n) + copy (s, 1, l - 1), copy (s, k, n) + copy (s, 1, k - 1));
  for i := 1 to v1 do begin
    x := random (n) + 1; t[x] := chr (97 - ord (t[x]));
  end;
  for i := 1 to v2 do begin
    x := random (n) + 1; s[x] := chr (97 - ord (s[x]));
  end;
  writeln (t);
  writeln (s);
end.