#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int t, n, m;
    string tmp;
    cin >> t;
    while (t--) {
        cin >> n >> m;
        vector<vector<int> > arr(m, vector<int> (26, 0));
        for (int i = 0; i < n; ++i) {
            cin >> tmp;
            for (int j = 0; j < m; ++j) arr[j][tmp[j] - 'a']++;
        }
        for (int i = 0; i < n - 1; ++i) {
            cin >> tmp;
            for (int j = 0; j < m; ++j) arr[j][tmp[j] - 'a']--;
        }
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < 26; ++j) {
                if (arr[i][j] == 1) {
                    cout << (char)(j + 'a');
                    break;
                }
            }
        }
        cout << endl;
    }
    return 0;
}