#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    long long int num, q;
    cin >> num >> q;
    long long int arr[num];
    for (long long int i = 0; i < num; i++) {
      cin >> arr[i];
    }
    long long int count = 0, ans = 0, flag = 0;
    for (long long int i = 0; i < num; i++) {
      if (flag == 0) {
        while (arr[i] <= arr[i + 1] && i < num - 1) {
          i++;
        }
        count += arr[i];
        flag = 1;
        continue;
      } else {
        while (arr[i] >= arr[i + 1] && i < num - 1) {
          i++;
        }
        if (i == num - 1) {
          break;
        } else {
          count -= arr[i];
          flag = 0;
        }
      }
    }
    if (flag == 0) {
      count += arr[num - 1];
    }
    cout << count << "\n";
  }
  return 0;
}
