#include <bits/stdc++.h>   using namespace std;   struct node {     int a;     int id;     bool operator<(const node &b) const {       if (a != b.a)         return a < b.a;       else         return id > b.id;     }   };   struct node que[305];   bool vis[305];   int main() {     int t, n, m;     scanf( %d , &t);     while (t--) {       memset(vis, 0, sizeof(vis));       scanf( %d%d , &n, &m);       for (int i = 1; i <= m; i++) {         scanf( %d , &que[i].a);         que[i].id = i;       }       sort(que + 1, que + m + 1);       long long ans = 0;       for (int i = 1; i <= m; i++) {         for (int j = 1; j < que[i].id; j++) ans += vis[j];         vis[que[i].id] = 1;       }       printf( %lld n , ans);     }     return 0;   }   