QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#6180. Rolling Snowman Game Problem

Statistics

In the Rolling Snowman game, $n$ snowmen of different types have already been stacked. These snowmen belong to one of three types: $A$, $B$, or $C$. The rules of the Rolling Snowman game are as follows: from the current queue of snowmen, choose any $2$ snowmen of different types and merge them into a new snowman of the type that is different from the two original types. For example, if you choose two snowmen of types $A$ and $B$, the new snowman will be of type $C$. If you choose types $A$ and $C$, the new snowman will be of type $B$; if you choose types $B$ and $C$, the new snowman will be of type $A$. The game ends when only snowmen of the same type remain in the queue. Xiao Ming and Xiao Xue want to complete the Rolling Snowman game using the minimum number of merges.

For a given queue of snowmen, calculate the type of the snowmen remaining in the queue after completing the Rolling Snowman game with the minimum number of merges.

Input

Each test case contains multiple sets of test data. The first line of each test data set contains a positive integer $n$, and the second line contains a string of length $n$ consisting of uppercase English letters A, B, and C, representing the initial queue of snowmen.

Output

For each test data set, output the type of the snowmen (A, B, or C) remaining in the queue after completing the Rolling Snowman game with the minimum number of merges. If the final type cannot be determined, output the uppercase letter N.

Examples

Input 1

5
ABCCC
3
ABC

Output 1

C
N

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.