Given N strings consisting of ‘R’ and ‘B’. Two strings can be only combined if last character of first string and first character of second string are same. Print the maximum length possible by combining strings.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting number of strings and the second line contains N space separated strings of equal length.
For each test case, in a new line print the maximum length possible. If no strings can combine then print "0".
RBR BBR RRR
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.