Input: arr[] = {2, 2, 7, 2, 5}, Q = 5, M = 8
queries[][] = {{1, 0, 3, 4},
{1, 4, 4, 2},
{1, 0, 0, 7},
{2, 1, 3},
{2, 3, 3}}
Output: {6, 3, 6}, {6}
Explanation: The states after performing each operation are:
After 1st: {6, 6, 3, 6, 5}
After 2nd: {6, 6, 3, 6, 7}
After 3rd: {5, 6, 3, 6, 7}
So in 4th query elements from index 1 to 3 and in 5th query element in index 3 are printed.
Input: arr[] = [2, 3, 4, 5], Q = 3, M = 6
queries[][] = {{1, 0, 0, 3},
{1, 1, 2, 2},
{1, 3, 3, 1},
{2, 0, 3}}
Output: {5, 5, 1, 1}