#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
int a[N];
int main()
{
    int T, n, m;
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        for (int i = 1; i <= n; i++)
            scanf("%d", a + i);
        for (int i = 2; i <= n; i++)
            a[i] += a[i - 1];
        while (m--)
        {
            int op, l, r;
            scanf("%d%d%d", &op, &l, &r);
            if (op == 2)
                printf("%d\n", a[r] - a[l - 1]);
        }
    }
    return 0;
}
