uses crt;
const dely=1500000;
var
f:file;
key:char;
_bb:byte;
a:array[1..8*6912]of byte;
a_sp:integer;
cikl:longint;
procedure _write_11;
begin
inc(a_sp);
write(1,' ');
a[a_sp]:=1;
end;
procedure _write_00;
begin
inc(a_sp);
a[a_sp]:=0;
write(0,' ');
end;

function wb(b:byte):string;
var s:string;
begin
s:='';
if (b and $80)=0 then s:=s+'0' else s:=s+'1';
if (b and $40)=0 then s:=s+'0' else s:=s+'1';
if (b and $20)=0 then s:=s+'0' else s:=s+'1';
if (b and $10)=0 then s:=s+'0' else s:=s+'1';
if (b and $08)=0 then s:=s+'0' else s:=s+'1';
if (b and $04)=0 then s:=s+'0' else s:=s+'1';
if (b and $02)=0 then s:=s+'0' else s:=s+'1';
if (b and $01)=0 then s:=s+'0' else s:=s+'1';
wb:=s;
end;

begin
assign(f,'data2');
rewrite(f,1);

clrscr;
while keypressed do readkey;
repeat
key:=#$FF;

{writeln(wb(port[$378]),' ',wb(port[$379]),' ',wb(port[$37A]));}
cikl:=0;
repeat
_bb:=port[$379];
inc(cikl);
until (((_bb and $10)=0))or(cikl>dely);
if (_bb and $40)=0 then _write_11 else _write_00;;

cikl:=0;
repeat
_bb:=port[$379];
inc(cikl);
until (((_bb and $10)<>0))or(cikl>dely);
if (_bb and $40)=0 then _write_11 else _write_00;;

until cikl>dely;
blockwrite(f,a[1],a_sp-1);
close(f);
end.