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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int, int>
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)    substr(a,b-a+1)
#define trace(x)    cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void solve(){
    int n, m;
    cin>>n>>m;
    string a[n];
    string b[n-1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    int count[m][26];
    memset(count, 0, sizeof(count));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            count[i][a[j][i]-'a']++;
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<n-1;j++){
            count[i][b[j][i]-'a']--;
        }
    }
    string ans="";
    for(int s=0;s<m;s++){
        for(int i=0;i<26;i++){
            if(count[s][i]%2){
                char c = 97 + i;
                ans += c;
            }
        }
    }
    cout<<ans<<endl;
} 

int32_t main(){

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    FIO;
    int t = 1;
    cin>>t;
    while(t--){
        solve();
    }
}