#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define endll "\n";

string findMissing(vector<string> &ogstr, vector<string> &shufstr){
	// map<pair<int, int>, int> mp;
	map<int, map<int, int> > mp;
	for(int i=0;i<ogstr.size();i++){
		for(int j=0;j<ogstr[i].size();j++){
			char c = ogstr[i][j];
			int char_int = (int)c-97;
			int index = j;
			mp[index][char_int]++;
			// map[make_pair(index, char_int)]++;
		}
	}
	for(int i=0;i<shufstr.size();i++){
		for(int j=0;j<shufstr[i].size();j++){
			char c = shufstr[i][j];
			int char_int = (int)c-97;
			int index = j;
			mp[index][char_int]--;
			// mp[make_pair(index, char_int)]--;
		}
	}
	string res="";
	for(int i=0;i<ogstr[0].size();i++){
		for(int j=0;j<26;j++){
			if(mp[i][j]==1){
				res+=(char)(j+97);
			}
		}
	}
	return res;

}

int main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif

    int t;
    cin>>t;
    while(t--){
    	int n;
    	cin>>n;

    	int m;
    	cin>>m;

    	vector<string> ogstr;
    	for(int i=0;i<n;i++){
    		string x;
    		cin>>x;
    		ogstr.push_back(x);
    	}
    	vector<string> shufstr;
    	for(int i=0;i<n-1;i++){
    		string x;
    		cin>>x;
    		shufstr.push_back(x);
    	}

    	string res = findMissing(ogstr, shufstr);
    	cout<<res<<endll;
    	cout<<flush;
    }
	return 0;
}