#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
#define out cout<<"\n" 
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define f(i,n) for(i==;i<n;i++)

 
// Think before writing code,it saves lot of time and gives clarity
// Don't be sad _shiv_ you can do it,its ok if u can't

ll max(ll a,ll b) { if(a>b) return a; return b; }
ll min(ll a,ll b) { if(a<b) return a; return b; }
ll gcd(ll a,ll b) { if(a==0)return b; return gcd(b%a,a); }
 
void init_code() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

int main() {
init_code();
ll d,t,i,j,k,n,l,k1,k2,y,r,k3,q,w,h,A,B,a,b,x,c,z,m;
cin>>t;
// t=1;
while(t--) {
    cin>>n>>m;
    l=0;
    vector<pair<char,ll>> v1,v2,v3;
    vector<pair<ll,char>> v4;
    string str;
    string str1,str2;
    for(i=0;i<n;i++) {
        cin>>str;
        for(j=0;j<m;j++) {
            v1.push_back({str[j],j});
        }
    }
    for(i=0;i<n-1;i++) {
        cin>>str;
        for(j=0;j<m;j++) {
            v2.push_back({str[j],j});
        }
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    for(i=0,j=0;j<v2.size()&&i<v1.size();) {
        if(v1[i].first!=v2[j].first) {
            v4.push_back({v1[i].second,v1[i].first});
            i++;
        }
        else if(v1[i].first==v2[j].first) {
            if(v1[i].second!=v2[j].second) {
                v4.push_back({v1[i].second,v1[i].first});
                i++;
            }
            else {
                i++,j++;
            }
        }

    }
    while(i<v1.size()) {
        v4.push_back({v1[i].second,v1[i].first});
        i++;
    }
    sort(v4.begin(),v4.end());
    for(i=0;i<v4.size();i++) {
        cout<<v4[i].second;
        fflush(stdout);
        cout.flush();
    }
    out;
}
return 0;
} 


























 
/*
ListNode* Solution::detectCycle(ListNode* A) {
   ListNode *temp=new ListNode(1);
   while(A) {
       if(A->next==NULL)
       return NULL;
       if(A->next==temp)
       return A;
       ListNode *t=A->next;
       A->next=temp;
       A=t;
   }
   return A;
}

///////////////
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
After this, we can define a data structure indexed_set that is like set but can be
indexed like an array. The definition for int values is as follows:
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;




int prime(int a) { 
    if(a==1||a==2) 
        return 0; 
    int arr[a+1]; 
    int ans=0;
        for(int i=2;i<=a;i++)
            arr[i]=1;
        
        for(int i=2;i*i<a;i++) {
            if(arr[i]==0) continue;
            for(int j=i*i;j<a;j+=i) {
                arr[j]=0;
            }
        }
        for(int i=2;i<a;i++) {
            if(arr[i]==1) ans++;
        }
         return ans;  
}

*/