#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin>>t;
  while(t--)
  {
      int n,m;
      cin>>n>>m;
      vector<int>a(m);
      for(auto &x:a)cin>>x;
      int max_v=-1e9,min_v=1e9;
      for(auto &x:a)min_v=min(min_v,x),max_v=max(max_v,x);
      reverse(a.begin(),a.end());
      int cur_p=n;
      long long int ans=0;
      for(auto &x:a)
      {
          if(cur_p==n||x==max_v)cur_p--,ans+=max_v;
          else cur_p++,ans+=min_v;
      }
      cout<<ans<<endl;
  }
}
