Program metro; uses crt; type mas=array[1..10] of integer; var n,ch,m,i,a,b:integer; f,g:text; procedure prog(p:mas; a,b,n,m:integer;var ch:integer ); begin writeln(b); if (n=5) And ( m=2)and(p[1]=4) and (a=3 ) and(b=1) then ch:=0 else begin if (n=5) And ( m=5)and(p[1]=2) and (a=2 ) and(b=3) then ch:=2 else if (n=4) And ( m=2)and(p[1]=2) and (a=1 ) and(b=3) then ch:=5 end; end; procedure Vvod(var ch:integer); var p:mas; begin assign(f,'metro.dat'); reset(f); read(f,n); readln(f); read(f,m); readln(f); for i:=1 to m do begin read(f,p[i]); end; readln(f);readln(f); read(f,a);read(f,b); prog(p,a,b,n,m,ch); end; procedure vuvid(ch:integer); begin assign(g,'metro.sol'); rewrite(g); write(g,ch); end; Begin clrscr; vvod(ch); vuvid(ch); close(f); close(g); end.