#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define gcd(a,b) __gcd(a,b)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) (int)a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterator
#define SET setprecision
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
#define mod1 1000000007
#define mod2 998244353
#define infmod 9223372036854775783
#define tc int t;cin>>t;while(t--)solve();
#define over(x) {cout<<x<<endl;return;}
#define intsz(x) (int)sz(to_string(x))
using namespace std;
int sum[100005][26];
void solve()
{
	FILL(sum,0);
	string a,b;
	int n,m;
	cin>>n>>m;
	REP(i,0,n){
		cin>>a;
		REP(j,0,m)
		sum[j][a[j]-'a']++;
	}
	REP(i,1,n){
		cin>>b;
		REP(j,0,m)
		sum[j][b[j]-'a']--;
	}
	REP(i,0,m)
	REP(j,0,26)
	if(sum[i][j])cout<<char(j+'a');
	cout<<endl;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	tc
    return 0;
}

