Given a sequence of integers a1,…,ana_1,\dots,a_na1,…,an , you need to process mmm operations.
In an operation xxx , you need to change a1,a2,…,axa_1,a_2,\dots,a_xa1,a2,…,ax to ax,…,a2,a1a_x,\dots,a_2,a_1ax,…,a2,a1 , and then query how many different kkk satisfies that there exists i,ji,ji,j that 1≤i≤x<j≤n1\le i\le x<j\le n1≤i≤x<j≤n s.t. ai=aj=ka_i=a_j=kai=aj=k .
Operations are NOT independent.
There is no 1≤i<j<k<l≤n1\le i<j<k<l\le n1≤i<j<k<l≤n s.t. ai=aj=ak=ala_i=a_j=a_k=a_lai=aj=ak=al
1≤ai≤n1\le a_i\le n1≤ai≤n
1≤x≤n1\le x\le n1≤x≤n
1≤n,m≤3×1051\le n,m\le 3\times 10^51≤n,m≤3×105