#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 1e+18
#define unique_arr(x) (x).resize(distance((x).begin(),unique(all(x))))//First sort the array
ll mod=1e9+7;
using namespace std;
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
ll power(ll x, ll y){ll res=1;x=x%mod;while (y > 0){if (y & 1)res = (res*x) % mod;y = y>>1;x = (x*x) % mod;}return res;}
//Power function logn (For large number using modulus)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE 
    freopen("input1.txt", "r", stdin); 
    freopen("output1.txt", "w", stdout); 
#endif 
    int t{1};  
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        vector<vector<int>>arr(m,vector<int>(26,0));
        vector<string>initial(n);
        for(int i=0;i<n;i++){
        	string s;
        	cin>>s;
        	initial[i]=s;
        	for(int j=0;j<m;j++){
        		char c=s[j];
        		arr[j][c-'a']++;
        	}
        }
        // for(int i=0;i<m;i++){
        // 	cout<<i<<"-->";
        // 	for(int j=0;j<26;j++)
        // 		cout<<arr[i][j]<<" ";
        // 	cout<<endl;
        // }
        for(int i=0;i<n-1;i++){
        	string s;
        	cin>>s;
        	for(int j=0;j<m;j++){
        		char c=s[j];
        		arr[j][c-'a']--;
        	}
        }
        // cout<<"============="<<endl;
        // for(int i=0;i<m;i++){
        // 	cout<<i<<"-->";
        // 	for(int j=0;j<26;j++)
        // 		cout<<arr[i][j]<<" ";
        // 	cout<<endl;
        // }
        string ans;
        for(int i=0;i<m;i++){
        	for(int j=0;j<26;j++){
        		if(arr[i][j]>=1){
        			ans.pb(j+'a');
        		}
        	}
        }
        cout<<ans<<endl;
    }
 return 0;
}
