#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
struct node1{
	string s;
	vector<int> c;
}strs[120000],ss1[120000];
void init(int n){
	for(int i = 1;i<=n;i++){
		strs[i].c.clear();
		strs[i].s = "";
		for(int j = 1;j <= 27;j++){
			strs[i].c.push_back(0);
		}
	}
}
signed main() {
	fio;
	int t;
	cin >> t;
	while(t--){
		int n,m;
		cin >> n >> m;		
		for(int i = 1;i <= n;i++){
			string s;
			cin >> s;
			strs[i].s = s;
		}
		for(int i = 1;i < n;i++){
			string s;
			cin >> s;
			ss1[i].s = s;
		}
		string ans = "";
		for (int i = 0; i < m; i++) {
			vector<int> chs(27,0);
            for(int j = 1;j <= n;j++){
            	++chs[strs[j].s[i] - 'a'];
			}
			for(int j = 1;j<n;j++){
				--chs[ss1[j].s[i] - 'a'];
			}
			for (int j = 0; j < 26; j++) {
                if (chs[j]) {
                    ans.push_back('a' + j);
                    break;
                }
            }
        }
        cout << ans <<endl;
	}
	return 0;
}