#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <string>
#include <fstream>
#include <iomanip>
#include <string>
#include <stdlib.h>
#include <sstream>
using namespace std;

void solve() {
	int a, b;
	cin >> a >> b;
	vector<string>A, B;
	for (int i = 0; i < a; i++) {
		string temp;
		cin >> temp;
		A.emplace_back(temp);
	}
	vector<vector<int>> Sum(b, vector<int>(26, 0));
	for (int i = 0; i < b; i++) {
		for (int j = 0; j < a; j++) {
			Sum[i][A[j][i] - 'a']++;
		}
	}
	for (int i = 0; i < a-1; i++) {
		string temp;
		cin >> temp;
		B.emplace_back(temp);
	}
	for (int i = 0; i < b; i++) {
		for (int j = 0; j < a - 1; j++) {
			Sum[i][B[j][i] - 'a']--;
		}
	}
	string answer = "";
	for (int i = 0; i < b; i++) {
		for (int j = 0; j < 26; j++) {
			if (Sum[i][j]) {
				answer += char('a' + j);
			}
		}
	}
	cout << answer << '\n';
	cout.flush();
}
int32_t main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}