DreamGrid has an interesting permutation of 1,2,…,n1,2,…,n denoted by a1,a2,…,ana1,a2,…,an. He generates three sequences ff, gg and hh, all of length nn, according to the permutation aa in the way described below: For each 1≤i≤n1≤i≤n, fi=max{a1,a2,…,ai}fi=max{a1,a2,…,ai}; For each 1≤i≤n1≤i≤n, gi...