#include #include #include #include #include #include #include #include #include #include #define LL long long #define pb push_back #define mp make_pair using namespace std; #define INF 1e9 const int MAXN = 100005; LL c[MAXN]; int lowbit(int n){ return n&(-n); } void update(int p, LL val){ while(p0){ sum += c[p]; p -= lowbit(p); } return sum; } int main(){ int T; int n,m; int i,j; int a,b; LL p; scanf("%d", &T); while(T--){ scanf("%d%d", &n, &m); memset(c,0,sizeof(c)); for(i=1; i