### PROBLEM LINKS

### DIFFICULTY

EASY

### EXPLANATION

Chef’s brother permutes the characters that Chef uses. This permutation has cycles. A cycle in a permutation is such that p[p[p[…p[i]…]]] = i; where p[x] depicts the position to which the item at x has been permuted to.

The key observation to this problem was that all the positions that participate in a cycle, need to have the same character. Thus the problem reduced to finding the number of cycles in the permutation, that Chef’s brother will do.

The largest number of cycles for any case could be 4892.

The result will be (26 to the power C), where C is the number of cycles.

### SETTER’S SOLUTION

Can be found here.

### TESTER’S SOLUTION

Can be found here.