#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#define ll long long
using namespace std;
void solve()
{
int moxi[11][11];
vector<string> v;
int n,m; cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>moxi[i][j];
if(n==1&&m==1)
{
cout<<-1<<endl;
return ;
}
v.clear();
for(int i=1;i<=n;i++)
{
string temp="";
for(int j=1;j<=m;j++)
temp+=to_string(moxi[i][j]);
v.push_back(temp);
}
string temp=*(v.begin());
v.erase(v.begin()); v.push_back(temp);
for(auto e:v)
{
char temp=e[0];
e.erase(e.begin());
e.push_back(temp);
for(auto f:e)
cout<<f<<' ';
cout<<endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t=1; cin>>t;
while(t--) solve();
return 0;
}
codeforces 说什么 wrong answer Integer parameter [name=a_i_j] equals to 0, violates the range [1, 10] (test case 91),导致我赛时wa了3 4 发,我没搞懂啊,我这输出和样例一模一样