Background
Before Albanian people could bear with the freedom of speech (this story is fully described in the problem “Freedom of speech”), another freedom - the freedom of choice - came down on them. In the near future, the inhabitants will have to face the first democratic Presidential election in the history of their country.
Outstanding Albanian politicians liberal Mohammed Tahir-ogly and his old rival conservative Ahmed Kasym-bey declared their intention to compete for the high post.
Problem
According to democratic traditions, both candidates entertain with digging dirt upon each other to the cheers of their voters’ approval. When occasion offers, each candidate makes an election speech, which is devoted to blaming his opponent for corruption, disrespect for the elders and terrorism affiliation. As a result the speeches of Mohammed and Ahmed have become nearly the same, and now it does not matter for the voters for whom to vote.
The third candidate, a chairman of Albanian socialist party comrade Ktulhu wants to make use of this situation. He has been lazy to write his own election speech, but noticed, that some fragments of the speeches of Mr. Tahir-ogly and Mr. Kasym-bey are completely identical. Then Mr. Ktulhu decided to take the longest identical fragment and use it as his election speech.
Input
The first line contains the integer number N (1 ≤ N ≤ 100000). The second line contains the speech of Mr. Tahir-ogly. The third line contains the speech of Mr. Kasym-bey. Each speech consists of N capital latin letters.
Output
You should output the speech of Mr. Ktulhu. If the problem has several solutions, you should output any of them.
Example input
28
VOTEFORTHEGREATALBANIAFORYOU
CHOOSETHEGREATALBANIANFUTURE
Example outputTHEGREATALBANIA
给你两个等长的串,求他们的最长公共连续子串.这里要求我们输出这个最长公共串了.(题目中要求有多解就输出所有解,但是其实只有1个解.)
对于输出解,我们只要记录过程中的每一个可以作为解的后缀编号以及长度即可一一输出.
AC代码: