#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e5 + 5;
typedef pair <int, int> ii;
#define foreach(i, c) 	for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) 	((c).find(x) != (c).end())
#define reset(x) memset((x),0,sizeof(x))
#define endl '\n'
#define fortune ""
#define bit(i,x)  (((x)>>(i))&1ll)
#define onbit(i,x)  ((x)|(1ll<<(i)))
#define offbit(i,x)  ((x)^(1ll<<(i)))
#define Count1(x) 	__builtin_popcountll((x))
#define fi 				first
#define se 			second
#define pb 			push_back
string s[100000 + 5];
int mark[100000 + 5][27];
int mark2[100000 + 5][27];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.flush();
	//freopen(fortune".inp", "r", stdin);
	//freopen(fortune".out", "w", stdout);
	int t, n, m;

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

		for (int i = 0; i <= m; i++)
			for (int j = 0; j <= 26; j++)
				mark[i][j] = mark2[i][j] = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> s[i];
			for (int j = 0; j < s[i].size(); j++)
				mark[j][s[i][j] - 'a']++;
		}
		for (int i = 1; i <= n - 1; i++)
		{
			string s1;
			cin >> s1;
			for (int j = 0; j < s1.size(); j++)
				mark2[j][s1[j] - 'a']++;
		}
		for (int i = 0; i <= m - 1; i++)
		{
			for (int j = 0; j <= 25; j++)
				if (mark[i][j] != mark2[i][j])
				{
					cout << char(j + 'a');
					break;
				}
		}
		cout << endl;
	}
	return 0;
}