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

#define fo(i, x, y) for (int i = (x); i <= (y); ++i)
#define fd(i, x, y) for (int i = (x); i >= (y); --i)

const int maxm = 1e5 + 5;

int n, m;
int cnt[maxm][26];
char s[maxm];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

void work()
{
	n = getint(); m = getint();
	fo(i, 1, m) memset(cnt[i], 0, sizeof(cnt[i]));
	fo(i, 1, n)
	{
		scanf("%s", s + 1);
		fo(j, 1, m) cnt[j][s[j] - 'a']++;
	}
	fo(i, 1, n - 1)
	{
		scanf("%s", s + 1);
		fo(j, 1, m) cnt[j][s[j] - 'a']--;
	}
	fo(i, 1, m)
		fo(j, 0, 25)
			if (cnt[i][j]){ putchar(j + 'a'); break;}
	printf("\n");
}

int main()
{
	//freopen("t.in", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);
	int T;
	T = getint();
	while (T--) work();
	fflush(stdout);
	return 0;
}
