Div II, 500 points

Possibility check can be done in a lot less code by using an int[26] array and adding char - 'A'