/* Main CP File */
#include <bits/stdc++.h>
#define int long long 
#define MOD 1000000007
#define pb push_back
#define all(a) a.begin(), a.end()
#define printarr(arr) for(int i=0; i<arr.size(); i++) cout << arr[i] << " "; cout << "\n";
using namespace std;

void init(){ 
    #ifndef ONLINE_JUDGE 
    freopen("../input.txt", "r", stdin); 
    freopen("../output.txt", "w", stdout); 
    #endif 
}
class Timer{private: chrono::time_point <chrono::steady_clock> Begin, End; public: Timer () : Begin(), End (){ Begin = chrono::steady_clock::now(); } ~Timer (){ End = chrono::steady_clock::now();cerr << "\nDuration: " << ((chrono::duration <double>)(End - Begin)).count()<< "s\n"; } }T;
/*----------------------------------------------------------------------------------*/


int32_t main(){
    init();
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int t; cin >> t;
    for(int l=1; l<=t; l++){
        int n, m; cin >> n >> m;
        vector<string>actual(n);
        vector<string>shuffled(n-1);
        for(int i=0; i<n; i++) cin >> actual[i];
        for(int i=0; i<n-1; i++) cin >> shuffled[i];

        string ans = "";
        for(int i=0; i<m; i++){
            map<char, int> m;
            for(int j=0; j<n-1; j++){
                m[shuffled[j][i]]++;
            }
            for(int j=0; j<n; j++){
                m[actual[j][i]]++;
            }
            for(auto it: m){
                if(it.second % 2 != 0){
                    ans.pb(it.first);
                }
            }
        }
        cout << ans << "\n";
    }
}