Please help in this code . why it giving runtime error. in vs code

#include

using namespace std;

string lcs(string, string);

int main()

{

int t;

cin >> t;

while (t--)

{

    int n, m, i, j, k;

    cin >> n >> m >> k;

    string a, b, c, temp;

    cin >> a >> b >> c;

    temp = lcs(a, b);

    a = lcs(b, c);

    b = lcs(a, temp);

    cout<<b<<"\n";

}

return 0;

}

string lcs(string a, string b)

{

int n, m, i, j, k, f;

n = a.size();

m = b.size();

string s;

int dp[n + 1][m + 1];

for (i = 0; i <= n; i++)

{

    f = 0;

    for (j = 0; j <= m; j++)

    {

        if (i == 0 || j == 0)

            dp[i][j] = 0;

        else if (a[i - 1] == b[i - 1])

        {

            if (f == 0)

                s += a[i - 1];

            dp[i][j] = 1 + dp[i - 1][j - 1];

            f = 1;

        }

        else

        {

            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

        }

    }

}

return s;

}
please answer me.
thanks for reading me