#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 201;
int t;
int main()
{
cin>>t;
while(t--)
{
int n,m,min1=1e6;
string s[N];
cin>>n>>m;
for(int i=0;i<n;i++) cin>>s[i];
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
int ans=0;
for(int k=0;k<m;k++)
{
ans+=abs(s[i][k]-s[j][k]);
}
min1=min(ans,min1);
}
}
cout<<min1<<'\n';
}
return 0;
}
/*
字符串数组
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 210;
int g[210][210];
int n, m;
int dx[] = {1, 1, -1, -1}, dy[] = {1, -1, -1, 1};
int get(int i, int j)
{
int sum = 0;
for(int s = 0; s < 4; s ++ )
{
for(int k = 1; k <= max(n, m); k ++ )
{
int x = dx[s] * k + i, y = dy[s] * k + j;
if(x <= n && y <= m && x >= 1 && y >= 1)
sum += g[x][y];
}
}
return sum;
}
void solve()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++ )
for(int j = 1; j <= m; j ++ ) cin >> g[i][j];
int maxv = 0;
for(int i = 1; i <= n; i ++ )
for(int j = 1; j <= m; j ++ )
maxv = max(maxv, g[i][j] + get(i, j));
cout << maxv << '\n';
}
int main()
{
int t;
cin >> t;
while ( t--) solve();
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 201000;
int t,a[N];
ll sum[N];
int main()
{
cin>>t;
while(t--)
{
memset(a,0,sizeof a);
memset(sum,0,sizeof sum);
int n,q,min1=1e7;
ll ans=0;
cin>>n>>q;
for(int i=1;i<=n;i++) scanf("%d",&a[i]),min1=min(min1,a[i]),ans+=a[i];
sort(a+1,a+1+n,greater<int>());
for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
//sort(sum+1,sum+1+n);
while(q--)
{
ll x;
cin>>x;
if(x>ans)
{
printf("-1\n");
}else{
ll l=0,r=n;
while(l<r)
{
ll mid=l+r>>1;
if(sum[mid]>=x) r=mid;
else l=mid+1;
}
//ll l=*lower_bound(sum+1,sum+1+n,x);
printf("%lld\n",l);
}
}
}
return 0;
}
//经典二分题,记得开LL,STL自带二分函数也行
比赛地址:Dashboard - Codeforces Round #790 (Div. 4) - Codeforces