#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <list>
#include <cstring>
#include <map>
#include <cstdio>
#include <set>
#include <utility>
using namespace std;
#define ll long long
#define mem(f, z) memset(f, z, sizeof(f))
#define foi(i, x, y) for (int i = (x), _en = (y); i <= _en; i++)
#define fod(i, x, y) for (int i = (x), _en = (y); i >= _en; i--)
#define INF 0x3f3f3f3f
inline long long read() {
    long long x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
int cnt[100050][30];
int main()
{
    int t = read();
    while(t--)
    {
        mem(cnt, 0);
        int n = read(), m = read();
        char s1[n + 5][m + 5];
        char s[m + 5];
        for(int i = 0; i < n; i++)
        {
            scanf("%s", s1[i]);
            for(int j = 0; j < m; j++)
            {
                cnt[j][s1[i][j] - 'a']++;
            }
        }
        for(int i = 0; i < n - 1; i++)
        {
            scanf("%s", s);
            for(int j = 0; j < m; j++)
            {
                cnt[j][s[j] - 'a']--;
            }
        }
        for(int i = 0; i < m; i++)
        {
            for(int j = 0; j < 30; j++)
            {
                if(cnt[i][j])
                {
                    s[i] = 'a' + j;
                    break;
                }
            }
        }
        s[m] = '\0';
        printf("%s\n", s);
    }
    return 0;
}