#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
int32_t mod = 1e9 + 7;

void solveCase()
{
    int n = 0, m = 0;
    cin >> n >> m;

    vector<vector<int>> mp(m, vector<int>(26, 0));
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int i = 0; i < m; i++)
            mp[i][s[i] - 'a']++;
    }
    for (int i = 0; i < n - 1; i++)
    {
        string s;
        cin >> s;
        for (int i = 0; i < m; i++)
            mp[i][s[i] - 'a']--;
    }

    for (int i = 0; i < m; i++)
        for (int x = 0; x < 26; x++)
            if (mp[i][x])
                cout << char('a' + x);
    cout << '\n';
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(NULL);
    int t = 0;
    cin >> t;
    while (t--)
        solveCase();
}