#include<bits/stdc++.h>
using namespace std;
#define ll long long int
typedef pair<ll, ll> iPair;
#define pb push_back
#define mp make_pair
#define sort1(v) sort(v.begin(),v.end())
#define sortdesc(v) sort(v.begin(),v.end(),greater<int>())
ll power(long long int x,long long int y,long long int p)
{
    long long int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main()
{

    //cin.tie(NULL);
    //ios_base::sync_with_stdio(false);
    fflush(stdout);
    int t;
    //t=1;
    cin>>t;
    for(int v=1;v<=t;v++)
    {
        int n,m;
        cin>>n>>m;
        string s[n];
        for(int i=0;i<n;i++)
        {
            cin>>s[i];
        }
        if(n==1)
            cout<<s[0]<<"\n";
        else
        {
            string s2[n-1];
            for(int i=0;i<n-1;i++)
            {
                cin>>s2[i];
            }
            string ans="";
            for(int i=0;i<m;i++)
            {
                vector<int>arr(26,0),arr2(26,0);
                for(int j=0;j<n;j++)
                {
                    arr[s[j][i]-'a']++;
                }
                for(int j=0;j<n-1;j++)
                {
                    arr2[s2[j][i]-'a']++;
                }
                for(int j=0;j<26;j++)
                {
                    if(arr[j]!=arr2[j])
                    {
                        ans+=(char)('a'+j);
                        break;
                    }
                }

            }
            cout<<ans<<"\n";
        }

    }


}

