#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using  namespace  std;

#define int long long
signed  main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);

    int t;
    cin >> t;

    while (t--)
    {
        int n, m;
        cin >> n >> m;
        if (n != 2)
            return -1234;
        vector<int> a(m);
        for (int i = 0; i < m; i++)
        {
            cin >> a[i];
        }
        vector<int> pp(m);
        vector<int> pm(m);
        vector<int> mp(m);
        vector<int> mm(m);
        pp[0] = a[0];
        pm[0] = max(a[0], -a[0]);
        mp[0] = max(a[0], -a[0]);
        mm[0] = -a[0];
        for (int i = 1; i< m; i++)
        {
            pp[i] = max(pm[i - 1], mp[i - 1]) + a[i];
            mp[i] = max(mm[i - 1] + a[i], pp[i - 1] - a[i]);
            pm[i] =  max(mm[i - 1] + a[i], pp[i - 1] - a[i]);
            mm[i] =  max(mp[i - 1], pm[i - 1]) - a[i];
        }
        cout << pp[m - 1] << "\n";
    }
}