Codeforces Round #183 Problem C Lucky Permutation Triple