
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int MxN = 1e5+1;
const int MxK = 1e9;
const int inf = INT_MAX;
#define REP0(i,n) for(int i=0; i<n; i++)
#define REP1(i,n) for(int i=1; i<=n; i++)
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define pb push_back
#define fi first
#define se second
#define reset(X) memset(X, 0, sizeof(X))
#define pii pair<int, int>
#define endl "\n"
#define vint vector<int>
#define pll pair<ll, ll>
#define vll vector<ll>
#define LOG 18 //enough for 10^5



void solve()
{
    int n,m;cin>>n>>m;
    string strings[n];
    REP0(i,n)cin>>strings[i];
    string changed[n-1];
    REP0(i,n-1)cin>>changed[i];
    
    
    string ans="";
    for(int pos=0; pos<m; pos++)
    {
        int count[26];
        reset(count);
        REP0(j,n)
        {
            count[(int)strings[j][pos]-97]++;
        }
        REP0(j, n-1)
        {
            count[(int)changed[j][pos]-97]--;
        }
        REP0(i, 26)
        {
            if(count[i]!=0)
            {
                ans+= (char)(97+i);
                break;
            }
        }
                  
                  
                  
                  
    }
                    
                    
    cout<<ans<<endl;
    
}





int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int t; cin>>t;  //t=1;
    while(t--)
    {
        solve();
    }
}

