QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 4 MB Total points: 10

#227. Palindrome [B]

Statistics

Pay attention to the small memory limit in this problem.

The computers of the Apollo moon landing rockets had 71 kilobytes of RAM. In this problem, you will have more at your disposal, a total of 4 MB of memory, and your task will be simpler: you must check whether the given input word is a palindrome. We remind you that a palindrome is a word that reads the same from left to right as it does from right to left, for example, kajak or inni.

To make it not too simple, in some tests, the length of the word will not be known before reading it.

Input

The first line of the input contains a single number $n$. In some test groups, this will be a positive number – in such a case, it denotes the length of the word that will be provided in the second line. In other test groups, $n = 0$, which means that you must read the word from the input without knowing its length beforehand.

The second line contains the word to be checked, consisting of lowercase English letters. This word is not empty, and its length does not exceed $20\,000\,000$ characters.

You may assume that in each test group, either all tests have $n > 0$, or in all of them $n = 0$.

Output

You should print a single line containing TAK or NIE depending on whether the given word is a palindrome.

Examples

Input 1

5
kajak

Output 1

TAK

Input 2

0
kanu

Output 2

NIE

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.