#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
    int n, m; cin >> n >> m;
    vector<string> a(n), b(n - 1);
    vector<vector<vector<int > > > f(2, vector<vector<int> >(m, vector<int>(26)));
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
        for (int j = 0; j < m; ++j) {
            f[0][j][a[i][j] - 'a']++;
        }
    }
    for (int i = 0; i < n - 1 ; ++i) {
        cin >> b[i];
        for (int j = 0; j < m; ++j) {
            f[1][j][b[i][j] - 'a']++;
        }
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < 26; ++j) {
            if (f[0][i][j] != f[1][i][j]) {
                cout << char(j + 'a');
                break;
            }
        }
    }
    cout << endl;

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    int t = 1;
    cin >> t;
    for (int i = 0; i < t; ++i)
    {
        solve();
    }
}