Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
//   ⠀⠀⠀⠀⠀⠀⢀⠆⠀⢀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡀⠀⠰⡀⠀⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⢠⡏⠀⢀⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢷⡀⠀⢹⣄⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⣰⡟⠀⠀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣧⠀⠀⢻⣆⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⢠⣿⠁⠀⣸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣇⠀⠈⣿⡆⠀⠀⠀⠀
//  ⠀⠀⠀⠀⣾⡇⠀⢀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡀⠀⢸⣿⠀⠀⠀⠀
//  ⠀⠀⠀⢸⣿⠀⠀⣸⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣇⠀⠀⣿⡇⠀⠀⠀
//  ⠀⠀⠀⣿⣿⠀⠀⣿⣿⣧⣤⣤⣤⣤⣤⣤⡀⠀⣀⠀⠀⣀⠀⢀⣤⣤⣤⣤⣤⣤⣼⣿⣿⠀⠀⣿⣿⠀⠀⠀
//  ⠀⠀⢸⣿⡏⠀⠀⠀⠙⢉⣉⣩⣴⣶⣤⣙⣿⣶⣯⣦⣴⣼⣷⣿⣋⣤⣶⣦⣍⣉⡉⠋⠀⠀⠀⢸⣿⡇⠀⠀
//  ⠀⠀⢿⣿⣷⣤⣶⣶⠿⠿⠛⠋⣉⡉⠙⢛⣿⣿⣿⣿⣿⣿⣿⣿⡛⠛⢉⣉⠙⠛⠿⠿⣶⣶⣤⣾⣿⡿⠀⠀
//  ⠀⠀⠀⠙⠻⠋⠉⠀⠀⠀⣠⣾⡿⠟⠛⣻⣿⣿⣿⣿⣿⣿⣿⣿⣟⠛⠻⢿⣷⣄⠀⠀⠀⠉⠙⠟⠋⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⢀⣤⣾⠿⠋⢀⣠⣾⠟⢫⣿⣿⣿⣿⣿⣿⡍⠻⣷⣄⡀⠙⠿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⣠⣴⡿⠛⠁⠀⢸⣿⣿⠋⠀⢸⣿⣿⣿⣿⣿⣿⡗⠀⠙⣿⣿⡇⠀⠈⠛⢿⣦⣄⠀⠀⠀⠀⠀
//  ⢀⠀⣀⣴⣾⠟⠋⠀⠀⠀⠀⢸⣿⣿⠀⠀⢸⣿⣿⣿⣿⣿⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠙⠻⣷⣦⣀⠀⣀
//  ⢸⣿⣿⠋⠁⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠈⣿⣿⣿⣿⣿⣿⠁⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠈⠙⣿⣿⡟
//  ⢸⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⢹⣿⣿⣿⣿⡏⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⡇
//  ⢸⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⢿⣿⣿⡿⠀⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⡇
//  ⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⠈⠿⠿⠁⠀⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀
//  ⠀⢻⣿⡄⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⢀⣿⡟⠀
//  ⠀⠘⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠃⠀
//  ⠀⠀⠸⣷⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⣾⠏⠀⠀
//  ⠀⠀⠀⢻⡆⠀⠀⠀⠀⠀⠀⠀⠸⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠇⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⠀⠀
//  ⠀⠀⠀⠀⢷⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⠀⠀⡾⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠈⢧⠀⠀⠀⠀⠀⠀⠀⠸⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⠇⠀⠀⠀⠀⠀⠀⠀⡸⠁⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⠀⠀⠀⠀⠀⠀⠀⠀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠣⠀⠀⠀⠀⠀⠀⠜⠀⠀⠀⠀⠀⠀⠀⠀⠀
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define lld long double
#define vi vector<ll>
#define vvi vector<vi>
#define vpi vector<pair<ll,ll>>
#define pb push_back
#define nl "\n"
#define csort(n) sort(n.begin(), n.end())
#define rsort(n) sort(n.begin(), n.end(), greater<ll>())
#define TxtIO                         \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define setbits(a) __builtin_popcountll(a) // to count 1 bits
#define trailing(a) __builtin_ctzll(a)     // to count trailing 0s
#define leading(a) __builtin_clzll(a)      // to count leading 0s
#define parity(a) __builtin_parityll(a)    // to check even odd
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod = 1e9 + 7;
ll const MAX = 1e8;
typedef unsigned long long ull;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

ll gcd(ll a, ll b)
{
    while (b != 0) {
        ll R = a % b;
        a = b;
        b = R;
    }
    return a;
}


ll fact(ll n , ll m)
{
    ll result = 1;
    for (ll i = 1; i <= n; ++i)
    {
        result = (result * i)%m ;
    }
    return result;
}



vector<ll> prime_fact(ll n)
{
    vector<ll> ans;
    for (ll i = 2; i <= sqrt(n); i++)
    {
        while (n % i == 0)
        {
            n = n / i;
            ans.push_back(i);
        }
    }
    if (n != 1)
    {
        ans.push_back(n);
    }
    return ans;
}

vector<bool> sieve(MAX, true);
vector<ll> primes;
void sieve_e(ll n)
{
    sieve[0] = false;
    sieve[1] = false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (sieve[i] == true)
        {
            for (ll j = i * i; j <= n; j += i)
            {
                sieve[j] = false;
            }
        }
    }
    for (int p = 2; p <= n; p++)
        if (sieve[p])
        {
            primes.push_back(p);
        }
}

vector<ll> spf(ll n)
{

    vector<ll> spf(1e7, 0);
    spf[1] = 1;

    for (ll i = 2; i <= n; i++)
    {
        if (spf[i] == 0)
        {
            spf[i] = i;
            for (ll j = i * i; j <= n; j += i)
                if (spf[j] == 0)
                    spf[j] = i;
        }
    }
    return spf;
}

bool is_prime(ll n)
{
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            return 0;
            break;
        }
    return 1;
}

ll exp(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = res * a;
        }
        a = a * a;
        b = b >> 1LL;
    }
    return res;
}

ll cd(ll number)
{
    if (number == 0)
    {
        return 1;
    }
    ll digits = floor(log10(abs(number))) + 1;
    return digits;
}

class node
{ // node definiton
    ll data;
    node *left;
    node *right;
    node(int val)
    {
        data = val;
        left = nullptr;
        right = nullptr;
    }
};

bool comp(pair<ll, ll> &a, pair<ll, ll> &b)
{
    // if(a.first!=b.first)    
    return  a.first > b.first ; 
    // else return a.second > b.second ; 

}

ll sum(vector<ll> &a)
{
    ll n = a.size();
    ll ans = 0;
    for (auto &it : a)
    {
        ans += it;
    }

    return ans;
}

pair<ll, ll> binarySearch2D(vector<vector<ll>> &grid, ll target)
{
    ll rows = grid.size() - 1;
    if (rows == 0)
        return {-1, -1}; // Handle empty grid
    ll cols = grid[0].size() - 1;
    ll low = 1, high = rows * cols;

    while (low <= high)
    {
        ll mid = low + (high - low) / 2;
        ll row = (mid - 1) / cols + 1;
        ll col = (mid - 1) % cols + 1;
        ll midValue = grid[row][col];
        if (midValue == target)
        {
            return {row, col}; // Assuming one-based indexing
        }
        else if (midValue < target)
        {
            low = mid + 1;
        }
        else
        {
            high = mid - 1;
        }
    }

    return {-1, -1}; // Element not found
}

vector<ll> factors(ll n)
{
    vector<ll> ans;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ans.push_back(i);
            if (n / i != i)
            {
                ans.push_back(n / i);
            }
        }
    }
    return ans;
}

ll root(ll x) {
    if (x < 2LL) return x;
    ll left = 1, right = 3*1e9, result = 0;
    while (left <= right) {
        ll mid = left + (right - left) / 2 ; 
        ll midSquared = mid * mid;
        if (midSquared == x) {
            return mid; 
        } else if (midSquared < x) {
            result = mid; 
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }
    return result; 
}

ll log_base_k(ll n, ll k) {
    ll result = 0;
    while (n >= k) {
        n /= k;
        result++;
    }
    return result;
}

ll mod_exp(ll base, ll exp, ll mod)
{
    ll result = 1;
    base = base % mod;
    while (exp > 0)
    {
        if (exp & 1LL)
        {
            result = (result * base) % mod;
        }
        exp = exp >> 1LL;
        base = (base * base) % mod;
    }
    return result;
}

ll ncr(ll n, ll r) {
    if (r > n) return 0;
    ll ans = 1;
    for (ll i = 0; i < r; i++) {
        ans = (ans * (n - i)) % mod;
        ans = (ans * mod_exp(i + 1LL, mod - 2LL, mod)) % mod;  
    }
    return ans;
}

ll mod_inverse(ll q, ll mod) {
    // Fermat's Little Theorem: Q^(-1) ≡ Q^(mod-2) (mod mod)
    return mod_exp(q, mod - 2LL, mod);
}

ll countOccurrences(const std::string& text, const std::string& pattern) {
    ll count = 0;
    size_t pos = text.find(pattern);

    while (pos != std::string::npos) {
        count++;
        pos = text.find(pattern, pos + 1); // Find the next occurrence
    }

    return count;
}

//---------------------------------------------------------------------------------------------------------------------------------------------
//FUNCTIONS RELATED TO PROBLEM
ll solve(ll i1 , ll i2 , string &a , string &b , string &c , string s){
    ll m = b.length() ; 
    ll n = a.length() ;
    if(i1>=a.length()){
        for (ll i = i2; i <m ; i++)
        {
            s+=b[i] ;
        }
        ll count = 0 ; 
        for (ll i = 0; i < m+n ; i++)
        {
            if(s[i]!=c[i]) count++ ; 
        }
        return count ; 
        
    }
    if(i2>=b.length()){
        for (ll i = i1; i <n ; i++)
        {
            s+=a[i] ;
        }
        ll count = 0 ; 
        for (ll i = 0; i < m+n ; i++)
        {
            if(s[i]!=c[i]) count++ ; 
        }
        return count ; 
    }
    s+=a[i1] ; 
    ll f1 = solve(i1+1,i2,a,b,c,s) ; 
    s.pop_back() ; 
    s+=b[i2] ; 
    ll f2 = solve(i1,i2+1,a,b,c,s) ; 
    return min(f1,f2) ; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
	freopen("Error.txt", "w", stderr);
    #endif
    ll t = 1;
    cin >> t;
    while(t--){
        string a,b,c ; 
        cin>>a>>b>>c ; 
        ll i1 = 0 , i2 = 0 ; 
        ll ans = solve(0,0,a,b,c,"") ; 
        cout<<ans<<nl ; 


    }
 }


Submission (verdict: Wrong answer on test 2):
//   ⠀⠀⠀⠀⠀⠀⢀⠆⠀⢀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡀⠀⠰⡀⠀⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⢠⡏⠀⢀⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢷⡀⠀⢹⣄⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⣰⡟⠀⠀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣧⠀⠀⢻⣆⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⢠⣿⠁⠀⣸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣇⠀⠈⣿⡆⠀⠀⠀⠀
//  ⠀⠀⠀⠀⣾⡇⠀⢀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡀⠀⢸⣿⠀⠀⠀⠀
//  ⠀⠀⠀⢸⣿⠀⠀⣸⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣇⠀⠀⣿⡇⠀⠀⠀
//  ⠀⠀⠀⣿⣿⠀⠀⣿⣿⣧⣤⣤⣤⣤⣤⣤⡀⠀⣀⠀⠀⣀⠀⢀⣤⣤⣤⣤⣤⣤⣼⣿⣿⠀⠀⣿⣿⠀⠀⠀
//  ⠀⠀⢸⣿⡏⠀⠀⠀⠙⢉⣉⣩⣴⣶⣤⣙⣿⣶⣯⣦⣴⣼⣷⣿⣋⣤⣶⣦⣍⣉⡉⠋⠀⠀⠀⢸⣿⡇⠀⠀
//  ⠀⠀⢿⣿⣷⣤⣶⣶⠿⠿⠛⠋⣉⡉⠙⢛⣿⣿⣿⣿⣿⣿⣿⣿⡛⠛⢉⣉⠙⠛⠿⠿⣶⣶⣤⣾⣿⡿⠀⠀
//  ⠀⠀⠀⠙⠻⠋⠉⠀⠀⠀⣠⣾⡿⠟⠛⣻⣿⣿⣿⣿⣿⣿⣿⣿⣟⠛⠻⢿⣷⣄⠀⠀⠀⠉⠙⠟⠋⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⢀⣤⣾⠿⠋⢀⣠⣾⠟⢫⣿⣿⣿⣿⣿⣿⡍⠻⣷⣄⡀⠙⠿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⣠⣴⡿⠛⠁⠀⢸⣿⣿⠋⠀⢸⣿⣿⣿⣿⣿⣿⡗⠀⠙⣿⣿⡇⠀⠈⠛⢿⣦⣄⠀⠀⠀⠀⠀
//  ⢀⠀⣀⣴⣾⠟⠋⠀⠀⠀⠀⢸⣿⣿⠀⠀⢸⣿⣿⣿⣿⣿⣿⡇⠀⠀⣿⣿⡇⠀⠀⠀⠀⠙⠻⣷⣦⣀⠀⣀
//  ⢸⣿⣿⠋⠁⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠈⣿⣿⣿⣿⣿⣿⠁⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠈⠙⣿⣿⡟
//  ⢸⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⢹⣿⣿⣿⣿⡏⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⡇
//  ⢸⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⢿⣿⣿⡿⠀⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⡇
//  ⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⠈⠿⠿⠁⠀⠀⠀⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀
//  ⠀⢻⣿⡄⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⢀⣿⡟⠀
//  ⠀⠘⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠃⠀
//  ⠀⠀⠸⣷⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⣾⠏⠀⠀
//  ⠀⠀⠀⢻⡆⠀⠀⠀⠀⠀⠀⠀⠸⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠇⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⠀⠀
//  ⠀⠀⠀⠀⢷⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⠀⠀⡾⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠈⢧⠀⠀⠀⠀⠀⠀⠀⠸⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⠇⠀⠀⠀⠀⠀⠀⠀⡸⠁⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⠀⠀⠀⠀⠀⠀⠀⠀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
//  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠣⠀⠀⠀⠀⠀⠀⠜⠀⠀⠀⠀⠀⠀⠀⠀⠀
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define lld long double
#define vi vector<ll>
#define vvi vector<vi>
#define vpi vector<pair<ll,ll>>
#define pb push_back
#define nl "\n"
#define csort(n) sort(n.begin(), n.end())
#define rsort(n) sort(n.begin(), n.end(), greater<ll>())
#define TxtIO                         \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define setbits(a) __builtin_popcountll(a) // to count 1 bits
#define trailing(a) __builtin_ctzll(a)     // to count trailing 0s
#define leading(a) __builtin_clzll(a)      // to count leading 0s
#define parity(a) __builtin_parityll(a)    // to check even odd
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod = 1e9 + 7;
ll const MAX = 1e8;
typedef unsigned long long ull;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

ll gcd(ll a, ll b)
{
    while (b != 0) {
        ll R = a % b;
        a = b;
        b = R;
    }
    return a;
}


ll fact(ll n , ll m)
{
    ll result = 1;
    for (ll i = 1; i <= n; ++i)
    {
        result = (result * i)%m ;
    }
    return result;
}



vector<ll> prime_fact(ll n)
{
    vector<ll> ans;
    for (ll i = 2; i <= sqrt(n); i++)
    {
        while (n % i == 0)
        {
            n = n / i;
            ans.push_back(i);
        }
    }
    if (n != 1)
    {
        ans.push_back(n);
    }
    return ans;
}

vector<bool> sieve(MAX, true);
vector<ll> primes;
void sieve_e(ll n)
{
    sieve[0] = false;
    sieve[1] = false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (sieve[i] == true)
        {
            for (ll j = i * i; j <= n; j += i)
            {
                sieve[j] = false;
            }
        }
    }
    for (int p = 2; p <= n; p++)
        if (sieve[p])
        {
            primes.push_back(p);
        }
}

vector<ll> spf(ll n)
{

    vector<ll> spf(1e7, 0);
    spf[1] = 1;

    for (ll i = 2; i <= n; i++)
    {
        if (spf[i] == 0)
        {
            spf[i] = i;
            for (ll j = i * i; j <= n; j += i)
                if (spf[j] == 0)
                    spf[j] = i;
        }
    }
    return spf;
}

bool is_prime(ll n)
{
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            return 0;
            break;
        }
    return 1;
}

ll exp(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = res * a;
        }
        a = a * a;
        b = b >> 1LL;
    }
    return res;
}

ll cd(ll number)
{
    if (number == 0)
    {
        return 1;
    }
    ll digits = floor(log10(abs(number))) + 1;
    return digits;
}

class node
{ // node definiton
    ll data;
    node *left;
    node *right;
    node(int val)
    {
        data = val;
        left = nullptr;
        right = nullptr;
    }
};

bool comp(pair<ll, ll> &a, pair<ll, ll> &b)
{
    // if(a.first!=b.first)    
    return  a.first > b.first ; 
    // else return a.second > b.second ; 

}

ll sum(vector<ll> &a)
{
    ll n = a.size();
    ll ans = 0;
    for (auto &it : a)
    {
        ans += it;
    }

    return ans;
}

pair<ll, ll> binarySearch2D(vector<vector<ll>> &grid, ll target)
{
    ll rows = grid.size() - 1;
    if (rows == 0)
        return {-1, -1}; // Handle empty grid
    ll cols = grid[0].size() - 1;
    ll low = 1, high = rows * cols;

    while (low <= high)
    {
        ll mid = low + (high - low) / 2;
        ll row = (mid - 1) / cols + 1;
        ll col = (mid - 1) % cols + 1;
        ll midValue = grid[row][col];
        if (midValue == target)
        {
            return {row, col}; // Assuming one-based indexing
        }
        else if (midValue < target)
        {
            low = mid + 1;
        }
        else
        {
            high = mid - 1;
        }
    }

    return {-1, -1}; // Element not found
}

vector<ll> factors(ll n)
{
    vector<ll> ans;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ans.push_back(i);
            if (n / i != i)
            {
                ans.push_back(n / i);
            }
        }
    }
    return ans;
}

ll root(ll x) {
    if (x < 2LL) return x;
    ll left = 1, right = 3*1e9, result = 0;
    while (left <= right) {
        ll mid = left + (right - left) / 2 ; 
        ll midSquared = mid * mid;
        if (midSquared == x) {
            return mid; 
        } else if (midSquared < x) {
            result = mid; 
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }
    return result; 
}

ll log_base_k(ll n, ll k) {
    ll result = 0;
    while (n >= k) {
        n /= k;
        result++;
    }
    return result;
}

ll mod_exp(ll base, ll exp, ll mod)
{
    ll result = 1;
    base = base % mod;
    while (exp > 0)
    {
        if (exp & 1LL)
        {
            result = (result * base) % mod;
        }
        exp = exp >> 1LL;
        base = (base * base) % mod;
    }
    return result;
}

ll ncr(ll n, ll r) {
    if (r > n) return 0;
    ll ans = 1;
    for (ll i = 0; i < r; i++) {
        ans = (ans * (n - i)) % mod;
        ans = (ans * mod_exp(i + 1LL, mod - 2LL, mod)) % mod;  
    }
    return ans;
}

ll mod_inverse(ll q, ll mod) {
    // Fermat's Little Theorem: Q^(-1) ≡ Q^(mod-2) (mod mod)
    return mod_exp(q, mod - 2LL, mod);
}

ll countOccurrences(const std::string& text, const std::string& pattern) {
    ll count = 0;
    size_t pos = text.find(pattern);

    while (pos != std::string::npos) {
        count++;
        pos = text.find(pattern, pos + 1); // Find the next occurrence
    }

    return count;
}

//---------------------------------------------------------------------------------------------------------------------------------------------
//FUNCTIONS RELATED TO PROBLEM
ll solve(ll i1, ll i2, string &a, string &b, string &c, vvi &dp) {
    ll m = b.length();
    ll n = a.length();

    if (i1 >= n) {
        ll count = 0;
        for (ll i = i2; i < m; i++) {
            if (b[i] != c[i1 + i2]) count++;
        }
        return count;
    }
    if (i2 >= m) {
        ll count = 0;
        for (ll i = i1; i < n; i++) {
            if (a[i] != c[i1 + i2]) count++;
        }
        return count;
    }

    if (dp[i1][i2] != -1) return dp[i1][i2];

    ll f1 = (a[i1] != c[i1 + i2]) + solve(i1 + 1, i2, a, b, c, dp);
    ll f2 = (b[i2] != c[i1 + i2]) + solve(i1, i2 + 1, a, b, c, dp);

    return dp[i1][i2] = min(f1, f2);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
	freopen("Error.txt", "w", stderr);
    #endif
    ll t = 1;
    cin >> t;
    while(t--){
        string a,b,c ; 
        cin>>a>>b>>c ; 
        ll m = b.length() ; 
        ll n = a.length() ;
        ll i1 = 0 , i2 = 0 ; 
        vvi dp(n+4,vi(m+4,-1)) ; 
        ll ans = solve(0,0,a,b,c,dp) ; 
        cout<<ans<<nl ; 

    }
 }