/*
    ----@sagittarius_k2-----
    Created by Ritesh Ranjan
*/

#define fio                          \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <ctime>
#include <cmath>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <list>

using namespace std;

#define int long long int
#define M 1000000007

bool sortBySec(const pair<int,int> &a, const pair<int,int> &b) {
    return (a.second < b.second);
}

int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

bool isPrime(int n) {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}

int powerOf2(int n) {
    if(n==0) return 1;
    else {
        if(n%2==0)
            return (powerOf2(n/2)%M*powerOf2(n/2)%M)%M;
        else return (powerOf2(n/2)%M*(powerOf2(n/2)*2)%M)%M;
    }
}

int power(int x, int y) {
    if(y==0) return 1;
    else {
        if(y%2==0)
            return (power(x, y/2)*power(x, y/2))%M;
        else return ((power(x, y/2)*power(x, y/2))%M*x%M)%M;
    }
}

signed main() {
    int t;
    cin>>t;
    while(t--) {
        int n, m;
        cin>>n>>m;
        vector<map<char, int>> m1(m);
        for(int i=0; i<n; i++) {
            string s;
            cin>>s;
            for(int j=0; j<m; j++) {
                m1[j][s[j]]++;
            }
        }
        for(int i=0; i<n-1; i++) {
            string s;
            cin>>s;
            for(int j=0; j<m; j++) {
                m1[j][s[j]]--;
            }
        }
        for(int i=0; i<m; i++) {
            for(auto j:m1[i]) {
                if(j.second!=0) {
                    cout<<j.first;
                    break;
                }
            }
        }
        cout<<"\n";
    }
}