Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.
Examples:
Non-string inputs should be converted to strings.
Return an array of arrays containing pairs of distinct indices that form palindromes. Pairs should be returned in the order they appear in the original list.
def palindrome_pairs(a):
    a = [str(x) for x in a];r = [];
    for k1,i in enumerate(a):
        for k2,j in enumerate(a):
            if i!=j and (i+j)==(i+j)[::-1]:r.append([k1,k2])
    return r
def palindrome_pairs(a):
    a = [str(x) for x in a];r = [];
    for k1,i in enumerate(a):
        for k2,j in enumerate(a):
            if i!=j and (i+j)==(i+j)[::-1]:r.append([k1,k2])
    return r