#include using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int n,m; scanf("%d%d",&n,&m); int mx=1e9+7; for(int i=0;i