Driver Code
if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 1 , 2 , 2 , 3 , 4 , 4 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE Q = [ Pair ( 1 , Pair ( 3 , 5 ) ) , Pair ( 1 , Pair ( 2 , 4 ) ) , Pair ( 1 , Pair ( 1 , 2 ) ) , Pair ( 2 , Pair ( 1 , 7 ) ) , Pair ( 1 , Pair ( 1 , 2 ) ) ] NEW_LINE SolveQuery ( arr , n , Q ) NEW_LINE DEDENT