Let *s* be a string whose length equals *n*. Its characters are numbered from 0 to *n* - 1, *i* and *j* are integers, 0 ≤ *i* &lt; *j* &lt; *n*. Let's define function *f* as follows:

*f*(*s*, *i*, *j*) = *s*[*i* + 1... *j* - 1] + *r*(*s*[*j*... *n* - 1]) + *r*(*s*[0... *i*]).

Here *s*[*p*... *q*] is a substring of string *s*, that starts in position *p* and ends in position *q* (inclusive); "+" is the string concatenation operator; *r*(*x*) is a string resulting from writing the characters of the *x* string in the reverse order. If *j* = *i* + 1, then the substring *s*[*i* + 1... *j* - 1] is considered empty.

You are given two strings *a* and *b*. Find such values of *i* and *j*, that *f*(*a*, *i*, *j*) = *b*. Number *i* should be maximally possible. If for this *i* there exists several valid values of *j*, choose the minimal *j*.
The first two input lines are non-empty strings *a* and *b* correspondingly. Each string's length does not exceed 10<sup class="upper-index">6</sup> characters. The strings can contain any characters with ASCII codes from 32 to 126 inclusive.
def lps(s):
    p = [0] * len(s)
    i, j = 1, 0
    while i < len(s):
        if s[i] == s[j]:
            j += 1
            p[i] = j
            i += 1
        else:
            if j != 0:
                j = p[j - 1]
            else:
                i += 1

    return p


def kmp(s1, s2, p):
    i, j = 0, 0

    m = [0] * len(s1)

    while i < len(s1):
        if s1[i] == s2[j]:
            j += 1
            m[i] = j
            i += 1

        if j == len(s2):
            j = p[j - 1]
        elif i < len(s1) and s1[i] != s2[j]:
            if j != 0:
                j = p[j - 1]
            else:
                i += 1

    return m


def solve():
    a = input()
    b = input()
    n = len(a)
    if n != len(b):
        print(-1, -1)
        return
    a_reversed = a[::-1]
    b_reversed = b[::-1]
    lps_a_reversed = lps(a_reversed)
    lps_b = lps(b)
    last = kmp(b, a_reversed, lps_a_reversed)
    mid = kmp(a, b, lps_b)

    i = 0
    ans = [-1, -1]
    while i < n - 1 and a[i] == b[n - 1 - i]:
        len_last = last[n - 2 - i]
        len_mid = mid[n - 1 - len_last]
        if len_last + len_mid >= n - 1 - i:
            ans = [i, n - len_last]
        i += 1

    print(" ".join(map(str, ans)))


solve()
