DP. ; var t,s,n,i,j,m,l,a,c,d:longint; f,e:array[..,..maxn] of longint; q:array[..] of longint; g:array[..maxn] of longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; begin readln(t,s,n); to s do begin readln(m,l,…