#include <bits/stdc++.h>
using namespace std;
#define int long long
#define bug(x) cout << #x << "  >>>>>>>  " << x << '\n'
#define _ << " , " <<
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define UNTIL(t) while (clock() < (t) * CLOCKS_PER_SEC)
#define SZ(a) (int)a.size()
const int MAX = 2000000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;
const double EPS = 1e-9;  //10^-9
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

   int t;

   cin >> t;

   while(t--) {
      int n, m;
      cin >> n >> m;
      vector<string> ori(n);

      vector<vector<int>> F(m + 1, vector<int>(30, 0));

      for(int i = 0; i < n; i++) {
         string s;
         cin >> s;
         for(int j = 0; j < m; j++)
            F[j][ s[j] - 'a' ]++;
      }
      
      for(int i = 0; i < n - 1; i++) {
         string s;
         cin >> s;
         for(int j = 0; j < m; j++)
            F[j][ s[j] - 'a' ]--;
      }

      string ans;

      for(int i = 0; i < m; i++) {
         for(int j = 0; j < 27; j++) {
            if(F[i][j]) {
               ans.push_back(char(j + 'a'));
               break;
            }
         }
      }

      cout << ans << endl;

   }

	return 0;
}

/*
   Before submit:
      Check the corners cases
      Check solution restrictions
 
   For implementation solutions:
      Check the flow of the variables
 
   For intervals problems:
      Think about two pointers
 
   For complete search:
      Think about cuts
 
   If you get WA:
      Reread your code looking for stupid typos
      Try various manual testcases
      Recheck the correctness of your algorithm
      Reread the statement
      Write a straightforward solution, create lots of testcases by yourself, and compare both solutions
      Change the coder (if you're with a team)
      Give up. You may have other tasks to solve.
*/