maxL([],_,_,AnsRow):-!, write(AnsRow). maxL([[A,B]|Rest],L,Row,_):- L1 is log(A)*B, L1>L, !, Row1 is Row+1, maxL(Rest,L1,Row1,Row). maxL([_|Rest],L,Row,AnsRow):- Row1 is Row+1, maxL(Rest,L,Row1,AnsRow). main:- see('pe99.txt'), read(R), seen, maxL(R,0,1,0).