// Cheese-Cracker: cheese-cracker.github.io
import std.stdio, std.conv, std.functional, std.string, std.algorithm;
import std.container, std.range, std.typecons, std.numeric, std.math, std.random;

alias ll = long;
alias rbt = redBlackTree;
alias tup = Tuple!(long, long);
static string[] inp;
T rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}
T[] rdarr(T = long)(T fix = 0){ auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
void show(A...)(A a) { debug{ foreach(t; a){ write(t, "| "); } writeln; } }
/*******************************It's a Me, Mario!*******************************************/

void play(){
    int n, q;
    n = rd!int;
    q = rd!int;
    ll[] arr = rdarr;
    if(n == 1){ writeln(arr[0]); return;}
    ll[] res;
    bool side = (arr[1] > arr[0]), nside;
    if(!side){ res ~= arr[0]; }
    foreach(i; 1..n){
        if(arr[i] > arr[i-1]){
            nside = 1;
        }else{
            nside = 0;
        }
        if(nside != side){
            res ~= arr[i-1];
            side = nside;
        }
    }
    if(side){ res ~= arr[n-1]; }
    /* writeln(res); */
    ll pow = 0;
    foreach(i; 0..res.length){
        if(i % 2 == 0){
            pow += res[i];
        }else if(i != res.length-1){
            pow -= res[i];
        }
    }
    writeln(pow);
}

int main(){
    long t = 1;
    t = rd;        // Toggle!
    while(t--) play();  // Let's play!
    stdout.flush;
    return 0;
}

