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

#define ll long long
#define ull unsigned long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ln "\n"
#define sc scanf
#define pr printf

const double EPS = (double) 1e-9;
const double pii = acos(-1);
const int mod = 1000000007;
const int N = (int) 1e5;
string a[N + 1], b[N + 1];
int freq1[N + 1][26], freq2[N + 1][26];

int main()
{
    fast_in_out;
    int test;
    cin >> test;
    for(int t = 1; t <= test; t++)
    {
        for(int i = 0; i <= N; i++)
        {
            for(int j = 0; j < 26; j++)
            {
                freq1[i][j] = 0;
                freq2[i][j] = 0;
            }
        }
        int n, m;
        cin >> n >> m;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            for(int j = 0; j < m; j++)
            {
                for(char ch = 'a'; ch <= 'z'; ch++)
                {
                    if(a[i][j] == ch)
                    {
                        freq1[j][ch - 'a']++;
                        break;
                    }
                }
            }
        }
        for(int i = 0; i < n - 1; i++)
        {
            cin >> b[i];
            for(int j = 0; j < m; j++)
            {
                for(char ch = 'a'; ch <= 'z'; ch++)
                {
                    if(b[i][j] == ch)
                    {
                        freq2[j][ch - 'a']++;
                        break;
                    }
                }
            }
        }
        string s = "";
        for(int i = 0; i < m; i++)
        {
            for(char ch = 'a'; ch <= 'z'; ch++)
            {
                if(freq1[i][ch - 'a'] != freq2[i][ch - 'a'])
                {
                    s += ch;
                    break;
                }
            }
        }
        cout << s << ln;
        cout.flush();
    }
}
