/*
Creater : 
    ANSHUMAN MISHRA
"All Losses In this World Are Due To Lack Of Ability.
If You Want To Curse Someone , Curse Your Own Weakness"
*/


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int,int>
#define yes cout<<"YES\n"
#define no cout<<"NO\n"

const int N=1e5+5;
int cnt[26][N];

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif

    int t=1;cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        for (int i=0;i<m;++i) for (int j=0;j<26;++j) cnt[j][i]=0;

        string s;
        for (int i=0;i<n;++i){
            cin>>s;
            for (int j=0;j<m;++j)
                cnt[s[j]-'a'][j]++;
        }
        /*
        for (int i=0;i<m;++i){
            for (int j=0;j<26;++j){
                /*
                if (cnt[j][i]==1){
                    ans+= (j+'a');
                    break;
                }
                cout<<cnt[j][i]<<' ';
            }
            cout<<'\n';
        }*/

        for (int i=0;i<n-1;++i){
            cin>>s;
            for (int j=0;j<m;++j)
                cnt[s[j]-'a'][j]--;
        }

        

        string ans="";
        for (int i=0;i<m;++i){
            for (int j=0;j<26;++j){
                
                if (cnt[j][i]==1){
                    ans+= (j+'a');
                    break;
                }
                //cout<<cnt[j][i]<<' ';
            }
            //cout<<'\n';
        }
        cout<<ans<<endl;
        cout.flush();

    }


    return 0;
}