Matchable Permutations

CodeChef - MATPER