#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll inf = 1e18;

int main()
{
  int t;
  cin >> t;
  while(t--)
    {
      int n, m;
      cin >> n >> m;
      ll dp[n + 1][m + 1];
      
      // dp[0][i] = 
      
      int x[m];
      for(int i = 0; i < m; i ++)
	cin >> x[i];
      
      for(int i = 0; i <= n; i ++)
	for(int j = 0; j <= m; j ++)
	  dp[i][j] = -inf;
      
      dp[n][m] = 0;
      
      for(int j = m - 1; j >= 0 ; j--)
	for(int i = 0; i <= n; i ++)
	  {
	    if(dp[i][j + 1] == -inf) continue;
	    
	    if(i + 1 <= n)
	      dp[i + 1][j] = max(dp[i+1][j], dp[i][j + 1] - x[j]);
	    if(i - 1 >= 0)
	      dp[i - 1][j] = max(dp[i-1][j], dp[i][j + 1] + x[j]);
	  }
      
      ll ans = -inf;
      for(int i = 0; i <= n; i ++)
	ans = max(ans, dp[i][0]);
      cout << ans << endl;
    }
  return 0;
}
