var e:array[1..10] of longint; w,d:array[1..50000] of longint; i,m,n,j:longint; procedure ss(x,y:longint); var ii,jj,s,o,aa:longint; begin ii:=x;jj:=y; s:=w[(x+y) shr 1]; aa:=d[(x+y) shr 1]; repeat while (w[ii]>s) or ((w[ii]=s) and (d[ii]aa)) do dec(jj); if ii<=jj then begin o:=w[ii];w[ii]:=w[jj];w[jj]:=o; o:=d[ii];d[ii]:=d[jj];d[jj]:=o; inc(ii);dec(jj); end; until ii>jj; if x