#include <iostream>
#include <vector>
using namespace std;

int tt, n, m;
string str[100005], reorder[100005];
int used[100005][28];

void solve(){
	cin >> n >> m;

	for(int i = 0; i < n; i++){
		cin >> str[i];
		for(int j = 0; j < m; j++){
			used[j][str[i][j]-'a']++;
		}
	}
	for(int i = 0; i < n-1; i++){
		cin >> reorder[i];
		for(int j = 0; j < m; j++){
			used[j][reorder[i][j]-'a']--;
		}
	}
	
	string ans = "";
	for(int i = 0; i < m; i++){
		for(int letter = 0; letter < 26; letter++){
			if(used[i][letter] == 1)
				cout << (char)('a' + letter);
			used[i][letter] = 0;
		}
	}
	cout << "\n";
	cout.flush();
}

int main(){
	cin >> tt;
	while(tt--)
		solve();
}
