#include<algorithm>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <ctime>
#include <set>
#include <map>
using namespace std;
int pd[100],sss[4]={0,2,6,19};
char dna[55][1005],ss[]="ACGT",s[1005];
int main(){
memset(s,0,sizeof(s)); //疯狂WA,奇怪的是样例也能过
int n,m,t,q;scanf("%d",&t);
while(t--){
//memset(s,0,sizeof(s));//AC、
scanf("%d%d",&n,&m);int sum = 0;
for(int i = 1; i <= n; i++)scanf("%s",dna[i]);
for(int j = 0; j < m; j++)
{
memset(pd,0,sizeof(pd));
for(int i = 1; i <= n; i++)pd[dna[i][j]]++;
int max = 0,x;
for(int k = 0; k < 4; k++)
if(pd[ss[k]] > max)
max = pd[ss[k]],s[j] = ss[k];
sum += max;
}puts(s);
printf("%d
",n*m-sum);
}return 0;
}
/*
Sample Input
3
5 8
TATGATAC
TAAGCTAC
AAAGATCC
TGAGATAC
TAAGATGT
4 10
ACGTACGTAC
CCGTACGTAG
GCGTACGTAT
TCGTACGTAA
6 10
ATGTTACCAT
AAGTTACGAT
AACAAAGCAA
AAGTTACCTT
AAGTTACCAA
TACTTACCAA
Sample Output
TAAGATAC
7
ACGTACGTAA
6
AAGTTACCAA
12
#include<bits/stdc++.h>
char dna[510][1010],s[1100];
int pos[4]={0,2,6,19},n,m;
int main(){
int t,pd[26];
scanf("%d",&t);
while(t--){
memset(s,0,sizeof(s));
scanf("%d%d",&m,&n);
for(int i = 0; i < m; i++)scanf("%s",dna[i]);
int sum = 0;
for(int j = 0; j < n; j++){
memset(pd,0,sizeof(pd));
for(int i = 0; i < m; i++ )
pd[dna[i][j]-'A']++;
int max = 0;
for(int i = 0; i < 4; i++)
if(max < pd[pos[i]])
max = pd[pos[i]],s[j] = pos[i]+'A';
sum += max;
}
puts(s);
printf("%d
",n*m-sum );
}
return 0;
}*/