Fix a Weird Speaker
题号:NC232330
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Mr.Colorful recently purchased a smart bluetooth speaker. He was quite satisfied with the speaker, except that something may went wrong when the speaker responds to him.


One day, Mr.Colorful found that the speaker produced a weird sentence, but he could not remember what exactly it said.

Based on impressions, Mr.Coloful was sure that the speaker wanted to say a sentence T , a string consisting of only lower case letters.

He believed that the sentence he heard sounded weird because a nonempty subinterval of T must have been repeated immediately after its occurrence.


Formally speaking, a string W is said to be a weird sentence originated from T, if and only if there exists two integers i, j , such that ,

where "+" means string concatenation and  means the substring of T located at .

Note that  denotes an empty string when .


Mr.Colorful opened the log of his speaker. The log is also a string S consisting of only lower case letters.

Given T, help Mr.Colorful to find the longest substring of S such that it is a weird sentence originated from T.

If there are multiple such strings, please output the string with the leftmost start position.

输入描述:

The input consists of:

    One line containing a string S, the log of the speaker.
    One line containing a string T, the sentence that Mr.Colorful believed the speaker originally wanted to say.

输出描述:

If in the log S there exists a weird sentence originated from T, please output two integers l and r seperated by a space, denoting the location of the longest weird sentence (the string is 1-indexed). You need to ensure that l is minimized.

Otherwise, output -1.

示例1

输入

复制
aabbbbcabbc
abbc

输出

复制
2 7

说明

In sample 1, "abbbbcc" is a weird sentence of "abbc" with substring "bb" repeated.
示例2

输入

复制
goodmorningiamarobrobothowareyousaythatagainiamaarobothhh
iamarobot

输出

复制
12 23

说明

In sample 2, "iamarobrobot" has "rob" repeated, and "iamaarobot" has "a" repeated. They both exist in the log. However, the previous one is longer.
示例3

输入

复制
baaaaaaaaaaabaaaaaaa
baaaa

输出

复制
1 9

说明

In sample 3, "baaaaaaaa" has "aaaa" repeated.
示例4

输入

复制
ninshufenmanjimabukenengzhedoushiyaoyaochuanbiexintamen
zhedoushiyaochuan

输出

复制
25 44
示例5

输入

复制
queshilidadapu
lidapu

输出

复制
7 14