# Get number of test cases t = int(input("Enter the number of test cases: ")) # Iterate through each test case for i in range(t): # Get input for current test case sizes = input("Enter the size of array and number of queries: ").split() n = int(sizes[0]) q = int(sizes[1]) arr = list(map(int, input("Enter the elements of array separated by space: ").split())) # Process queries for current test case for j in range(q): query = list(map(int, input("Enter the query: ").split())) # Execute query type 1 if query[0] == 1: l = query[1] - 1 r = query[2] - 1 k = query[3] arr[l:r + 1] = [x + k for x in arr[l:r + 1]] # Execute query type 2 elif query[0] == 2: l = query[1] - 1 r = query[2] - 1 k = query[3] arr[l:r + 1] = [x * k for x in arr[l:r + 1]] # Execute query type 3 elif query[0] == 3: l = query[1] - 1 r = query[2] - 1 print(sum(arr[l:r + 1])) # Print sum of elements in range [l, r]