public static bool solve(string str1, string str2, string str3)
var match = new bool[m+1, n+1];
for (int i = m; i >= 0; i--)
for (int j = n; j >= 0; j--)
match[i,j] = (i == m && j == n) ||
(i < m && str1[i] == str3[i+j] && match[i+1,j]) ||
(j < n && str2[j] == str3[i+j] && match[i,j+1]);
public static void Main()
Console.WriteLine("version 8");
Console.WriteLine(solve("124", "53", "12345"));