You need to implement a function that evaluates whether a series of tower configurations can be classified as "beautiful." A configuration is considered "beautiful" if it contains at most one adjacent pair of the same type of tower when combining two sequences of towers.
t: An integer representing the number of test cases (1 ≤ t ≤ 1000).
test_cases: A list of tuples, where each tuple consists of four elements:
n: An integer representing the number of towers in the first sequence (1 ≤ n ≤ 10^5).
m: An integer representing the number of towers in the second sequence (1 ≤ m ≤ 10^5).
a: A string of length n where each character represents the type of tower in the first sequence.
b: A string of length m where each character represents the type of tower in the second sequence.
Output:
A list of strings, each string being "YES" if the combined tower configuration is beautiful (at most one pair of adjacent towers of the same type), or "NO" otherwise.
Implementation Requirements
Reverse string b before combining with a.
Count the number of adjacent pairs of the same type in the combined tower configuration.
Return a list of results corresponding to each test case.
File Location
The solution must be implemented in a file named /app/solution.py.