Given N strings, two strings are said to be connectable if number of set bits in integer representation of last char of first string are equal to first char of second string. We have to determine if it is possible to form a ring chain by using all the strings.
Integer representation of 'A' is 0 ,'B' is 1 and so on 'Z' is 25.
1<=N<=10^4
Example -
N=3
BBD FAC CZE
Output - POSSIBLE
Ring can be formed as BBD->FAC->CZE->BBD