#include <bits/stdc++.h>

/**
 * Code by: Om Kumar
 * Dated: 7/11/21
 */

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define rep(i, n) for(int i = 0; i < n; i++)
#define run(i, a, b) for(int i = a; i < b; i++)
#define cinarr(arr, n) rep(_i, n) cin >> arr[_i]
#define cinset(st, n) int _t; rep(i, n) {cin >> _t; st.insert(_t);}
#define coutarr(arr, n) rep(_i, n) cout << arr[_i] << " "; cout << endl
#define coutvec(vec) for(auto _e: vec) cout << _e << " "; cout << endl;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

int main() {
    FAST_IO

    int T;
    cin >> T;

    while (T--) {
        int n, m;
        cin >> n >> m;

        vector<string> a(n);
        cinarr(a, n);

        vector<string> b(n - 1);
        cinarr(b, n - 1);

        vector<vi> f(m, vi(26, 0));

        rep(i, n){
            string &s = a[i];
            rep(j, m){
                f[j][s[j] - 'a']++;
            }
        }

        rep(i, n - 1){
            string &s = b[i];
            rep(j, m){
                f[j][s[j] - 'a']--;
            }
        }

        rep(i, m){
            rep(j, 26){
                if(f[i][j] == 1){
                    cout << (char)('a'  + j);
                    break;
                }
            }
        }

        cout << endl;
    }
}
