#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);


void solve(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> orig(m,vector<ll>(26));
    vector<vector<ll>> diff(m,vector<ll>(26));
    for(ll i=0;i<n;i++){
        string s;
        cin>>s;
        for(ll j=0;j<m;j++){
            orig[j][s[j]-'a']++;
        }
    }
    for(ll i=0;i<n-1;i++){
        string s;
        cin>>s;
        for(ll j=0;j<m;j++){
            diff[j][s[j]-'a']++;
        }
    }
    for(ll i=0;i<m;i++){
        for(ll j=0;j<26;j++){
            if(orig[i][j]!=diff[i][j]){
                cout<<char(97+j);
            }
        }
    }
    cout<<endl;
}

int main(){
    FAST1;
    FAST2;
    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}