What will be the output for this test case

ABabcba
bbbaaa
Actually I didn’t get what will be answer for some of the test cases.

ab contains all…