AtCoder Regular Contest 059 - Unbalanced

Given a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both `voodoo` and `melee` are unbalanced, while neither `noon` nor `a` is.

You are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.

Constraints

* 2 ≦ |s| ≦ 10^5
* s consists of lowercase letters.

Input

The input is given from Standard Input in the following format:


s


Output

If there exists no unbalanced substring of s, print `-1 -1`.

If there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print `a b`. If there exists more than one such substring, any of them will be accepted.

Examples

Input

needed


Output

2 5


Input

atcoder


Output

-1 -1

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
S = input()
(s, e) = (-1, -1)
if len(S) == 2 and S[0] == S[1]:
	(s, e) = (1, 2)
for i in range(len(S) - 2):
	if S[i] == S[i + 1] or S[i] == S[i + 2] or S[i + 1] == S[i + 2]:
		(s, e) = (i + 1, i + 3)
		break
print(s, e)


S = input() + 'X'
N = len(S)
(A, B) = (-1, -1)
for i in range(N - 2):
	if S[i] == S[i + 1]:
		(A, B) = (i + 1, i + 2)
	if S[i] == S[i + 2]:
		(A, B) = (i + 1, i + 3)
print(A, B)


s = input()
s_len = len(s)
for i in range(s_len - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		exit()
	if i != s_len - 2 and s[i] == s[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


l = input() + '_'
x = y = -2
for i in range(len(l) - 2):
	if l[i] == l[i + 1]:
		x = i
		y = i + 1
	if l[i] == l[i + 2]:
		x = i
		y = i + 2
print(x + 1, y + 1)


txt = input()
L = len(txt)

def solve():
	for i in range(L - 1):
		if txt[i] == txt[i + 1]:
			return ' '.join([str(x) for x in [i + 1, i + 2]])
	for i in range(L - 2):
		if txt[i] == txt[i + 2]:
			return ' '.join([str(x) for x in [i + 1, i + 3]])
	return '-1 -1'
ans = solve()
print(ans)


s = input()
n = len(s)
if s[0] == s[1]:
	print(1, 2)
	exit(0)
a = -1
b = -1
for i in range(n - 2):
	d = {}
	for j in range(3):
		t = s[i + j]
		if t not in d:
			d[t] = 1
		else:
			a = i + 1
			b = i + j + 1
			print(a, b)
			exit(0)
print(a, b)


s = input()
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(str(i + 1) + ' ' + str(i + 2))
		break
	if i != len(s) - 2 and s[i] == s[i + 2]:
		print(str(i + 1) + ' ' + str(i + 3))
		break
else:
	print('-1 -1')


s = input()
for i in range(len(s) - 2):
	if s[i] == s[i + 1] or s[i] == s[i + 2]:
		print(i + 1, end=' ')
		print(i + 3)
		exit()
if s[-2] == s[-1]:
	print(len(s) - 1, end=' ')
	print(len(s))
	exit()
print('-1 -1')


s = input()
for i in range(len(s) - 2):
	temp = s[i]
	if temp == s[i + 1] or temp == s[i + 2]:
		print(i + 1, i + 3)
		exit()
if len(s) == 2 and len(set(s)) == 1:
	print(1, 2)
else:
	print(-1, -1)


S = input()
for i in range(1, len(S)):
	if S[i] == S[i - 1]:
		print(i, i + 1)
		break
	if i > 1 and S[i] == S[i - 2]:
		print(i - 1, i + 1)
		break
else:
	print(-1, -1)


S = input()
for c in range(0, ord('z') - ord('a') + 1):
	last_c = -1
	for (i, s) in enumerate(S):
		if ord(s) - ord('a') == c:
			if last_c == -1:
				last_c = i
				continue
			if i - last_c <= 2:
				print(last_c + 1, i + 1)
				exit()
			last_c = i
print(-1, -1)


S = input()
bb = S[0]
b = S[1]
flag = False
if bb == b:
	flag = True
	print('1 2')
if len(S) > 2:
	for i in range(2, len(S)):
		if flag:
			break
		if S[i] == b or S[i] == bb:
			flag = True
			print(str(i - 1) + ' ' + str(i + 1))
			break
		(bb, b) = (b, S[i])
if not flag:
	print('-1 -1')


s = input()
if len(s) == 2:
	if s[0] == s[1]:
		print(1, 2)
	else:
		print(-1, -1)
	exit()
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		exit()
for i in range(len(s) - 2):
	if s[i] == s[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


import sys
s = input()
a = 'qwertyuiopasdfghjklzxcvbnm'
for i in a:
	for n in range(len(s) - 1):
		if i + i == s[n:n + 2]:
			print(n + 1, n + 2)
			sys.exit()
	for n in range(len(s) - 2):
		if i == s[n] and i == s[n + 2]:
			print(n + 1, n + 3)
			sys.exit()
print(-1, -1)


import sys
s = input()
n = len(s)
for i in range(1, n):
	if s[i] == s[i - 1]:
		print(i)
		print(i + 1)
		sys.exit()
	if i > 1 and s[i] == s[i - 2]:
		print(i - 1)
		print(i + 1)
		sys.exit()
print(-1)
print(-1)


s = input()
if len(s) == 2:
	if s[0] == s[1]:
		print(1, 2)
	else:
		print(-1, -1)
	exit(0)
for (i, (a, b, c)) in enumerate(zip(s, s[1:], s[2:]), 1):
	if a == b:
		print(i, i + 1)
		exit(0)
	if a == c:
		print(i, i + 2)
		exit(0)
print(-1, -1)


def main():
	s = input().strip()
	if len(s) < 2:
		print(-1)
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			print(i + 1, i + 2)
			return
		if i + 2 < len(s) and s[i] == s[i + 2]:
			print(i + 1, i + 3)
			return
	print(-1, -1)
main()


import sys
import os
S = input()
lenght = len(S)
flg = 0
if lenght == 2 and S[0] == S[1]:
	print(1, 2)
	sys.exit()
for i in range(lenght - 2):
	if S[i] == S[i + 1]:
		print(i + 1, i + 2)
		sys.exit()
	if S[i] == S[i + 2]:
		print(i + 1, i + 3)
		sys.exit()
print(-1, -1)


S = input()
l = -1
r = -1
for i in range(len(S) - 1):
	if S[i] == S[i + 1]:
		l = i + 1
		r = i + 2
		break
if l < 0 and len(S) > 2:
	for i in range(len(S) - 2):
		if S[i] == S[i + 2]:
			l = i + 1
			r = i + 3
			break
print(l, r)


s = input()
n = len(s)
(e, p, r) = (exit, print, range)
for i in r(n - 1):
	if s[i] == s[i + 1]:
		e(p(i + 1, i + 2))
for i in r(n - 2):
	if s[i] == s[i + 2]:
		e(p(i + 1, i + 3))
p(-1, -1)


s = input()
ans = [-1, -1]
for i in range(len(s) - 2):
	if s[i] == s[i + 2]:
		ans = [i + 1, i + 2 + 1]
		break
	if s[i] == s[i + 1]:
		ans = [i + 1, i + 2]
		break
if s[len(s) - 2] == s[len(s) - 1]:
	ans = [len(s) - 1, len(s)]
print(ans[0], ans[1])


s = list(input())
n = len(s)
check = False
for i in range(n - 2):
	temp = s[i:i + 3]
	temp.sort()
	if temp[1] == temp[0] or temp[1] == temp[2]:
		check = True
		print(i + 1, i + 1 + 2)
		break
if n == 2 and s[0] == s[1]:
	check = True
	print('1 2')
if check == False:
	print('-1 -1')


s = list(input())
ls = len(s)
for i in range(1, ls):
	if s[i] == s[i - 1]:
		print(i, i + 1)
		break
	if i == 1:
		continue
	if s[i] == s[i - 2]:
		print(i - 1, i + 1)
		break
else:
	print(-1, -1)


s = input()
res = False
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		res = (i, i + 1)
		break
for i in range(len(s) - 2):
	if s[i] == s[i + 2]:
		res = (i, i + 2)
		break
if res:
	res = list(map(lambda x: x + 1, res))
	print(res[0], res[1])
else:
	print('-1 -1')


S = input()
if len(S) == 2:
	if S[0] == S[1]:
		print('1 2')
		exit()
else:
	for i in range(len(S) - 2):
		if any([S[i:i + 3].count(S[j]) >= 2 for j in range(i, i + 3)]):
			print(i + 1, i + 3)
			exit()
print('-1 -1')


s = input()
slist = list(s)
slen = len(slist)
res = [-1, -1]
for i in range(slen):
	if i + 1 <= slen - 1:
		if slist[i] == slist[i + 1]:
			res = [i + 1, i + 2]
			break
	if i + 2 <= slen - 1:
		if slist[i] == slist[i + 2]:
			res = [i + 1, i + 3]
			break
print(res[0], res[1])


import collections
s = input()
ls = len(s)
if ls == 2 and s[0] != s[1]:
	print(-1, -1)
	exit()
elif ls == 2 and s[0] == s[1]:
	print(1, 2)
	exit()
for i in range(2, ls):
	tmp = collections.Counter(s[i - 2:i + 1])
	if len(tmp.keys()) <= 2:
		print(i - 1, i + 1)
		exit()
print(-1, -1)


from string import ascii_lowercase
s = input()
for x in ascii_lowercase:
	cnt = 0
	l = 0
	for (r, y) in enumerate(s):
		if y == x:
			cnt += 1
		else:
			cnt -= 1
		if r - l > 0 and cnt > 0:
			print(l + 1, r + 1)
			exit()
		if y == x:
			l = r
			cnt = 1
print(-1, -1)


s = input()
n = len(s)
for i in range(n - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		exit()
for i in range(n - 2):
	if s[i] == s[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = input()
b = ''
ans = [-1, -1]
for i in range(len(s)):
	a = s[i]
	if a == b:
		ans = [i, i + 1]
	b = s[i]
b = ''
for i in range(0, len(s), 2):
	a = s[i]
	if a == b:
		ans = [i - 1, i + 1]
	b = s[i]
b = ''
for i in range(1, len(s), 2):
	a = s[i]
	if a == b:
		ans = [i - 1, i + 1]
	b = s[i]
print(*ans)


def main():
	S = input()
	for i in range(len(S) - 1):
		if S[i] == S[i + 1]:
			print(str(i + 1) + ' ' + str(i + 2))
			exit()
	for i in range(len(S) - 2):
		if S[i] == S[i + 2]:
			print(str(i + 1) + ' ' + str(i + 3))
			exit()
	print('-1 -1')
main()


from collections import defaultdict
s = input()
dd = defaultdict(list)
for (i, c) in enumerate(s):
	dd[c].append(i)

def solve(ls):
	for (x, y) in zip(ls, ls[1:]):
		if y - x <= 2:
			return (True, (x + 1, y + 1))
	return (False, None)
for (k, v) in dd.items():
	(is_yes, ans) = solve(v)
	if is_yes:
		print(*ans)
		break
else:
	print(-1, -1)


def ARC059D():
	s = input()
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			print(i + 1, i + 2)
			return 0
	for i in range(len(s) - 2):
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			return 0
	print(-1, -1)
ARC059D()


s = input()
L = len(s)
for i in range(L - 2):
	if s[i + 1] == s[i] or s[i + 2] == s[i]:
		print(i + 1, i + 3)
		exit()
else:
	if s[L - 2] == s[L - 1]:
		print(L - 1, L)
	else:
		print(-1, -1)


s = input()
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		quit()
for i in range(len(s) - 2):
	if s[i] == s[i + 2]:
		print(i + 1, i + 3)
		quit()
print(-1, -1)


import sys

def LS2():
	return list(sys.stdin.readline().rstrip())
S = LS2()
N = len(S)
for i in range(N - 1):
	if S[i] == S[i + 1]:
		print(i + 1, i + 2)
		exit()
for i in range(N - 2):
	if S[i] == S[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = input().rstrip()
for i in range(len(s)):
	if 1 <= i and s[i - 1] == s[i]:
		print(i, i + 1)
		exit()
	if 2 <= i and s[i - 2] == s[i]:
		print(i - 1, i + 1)
		exit()
print(-1, -1)


s = input()
if len(s) == 2 and s[0] == s[1]:
	print(1, 2)
	exit()
for i in range(len(s) - 2):
	if len(set(s[i:i + 3])) != 3:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


import sys
readline = sys.stdin.readline
s = [-1, -2] + list(map(ord, readline().strip()))
N = len(s)
ans = (-1, -1)
for i in range(2, N):
	if s[i] == s[i - 1]:
		ans = (i - 2, i - 1)
		break
	if s[i] == s[i - 2]:
		ans = (i - 3, i - 1)
		break
print(*ans)


s = input()
if s[0] == s[1]:
	print(1, 2)
	exit()
for i in range(2, len(s)):
	if s[i] == s[i - 1] or s[i] == s[i - 2]:
		print(i - 1, i + 1)
		break
else:
	print(-1, -1)


import sys
S = input().strip()
for i in range(2, 4):
	for j in range(0, len(S) + 1 - i):
		s = S[j:j + i]
		for k in set(s):
			if s.count(k) * 2 > len(s):
				print(j + 1, j + i)
				sys.exit(0)
print(-1, -1)


S = input()
N = len(S)
for i in range(N - 1):
	c2 = S[i:i + 2]
	c3 = S[i:i + 3]
	if len(set(c2)) == 1:
		print(i + 1, i + 2)
		exit()
	if i != N - 2 and len(set(c3)) == 2:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = input()
for i in range(len(s) - 2):
	t = s[i:i + 3]
	if t[0] == t[1] or t[0] == t[2] or t[1] == t[2]:
		print(i + 1, i + 3)
		break
else:
	if len(s) == 2:
		if s[0] == s[1]:
			print(1, 2)
		else:
			print(-1, -1)
	else:
		print(-1, -1)


s = input()
for i in range(len(s) - 2):
	if s[i] == s[i + 1] or s[i] == s[i + 2]:
		print('{} {}'.format(i + 1, i + 3))
		break
else:
	if s[-2] == s[-1]:
		print('{} {}'.format(len(s) - 1, len(s)))
	else:
		print('-1 -1')


s = input()
is_unbalanced = False
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		is_unbalanced = True
		break
if is_unbalanced == False:
	for i in range(len(s) - 2):
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			is_unbalanced = True
			break
if is_unbalanced == False:
	print(-1, -1)


s = input()
n = len(s)
for i in range(n - 1):
	t = s[i:i + 2]
	if t[0] == t[-1]:
		print(i + 1, i + 2)
		exit(0)
for i in range(n - 2):
	t = s[i:i + 3]
	if t[0] == t[-1] and t[0] != t[1]:
		print(i + 1, i + 3)
		exit(0)
print(-1, -1)


s = input()
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		break
	try:
		if s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
			print(i + 1, i + 3)
			break
	except:
		pass
else:
	print(-1, -1)


def main():
	s = input().strip()
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			print(i, i + 1)
			break
	else:
		for i in range(2, len(s)):
			if s[i] == s[i - 2]:
				print(i - 1, i + 1)
				break
		else:
			print(-1, -1)
main()


s = input()
(a, b) = (-1, -1)
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		(a, b) = (i + 1, i + 2)
		break
if a + b == -2:
	for i in range(len(s) - 2):
		if s[i] == s[i + 2]:
			(a, b) = (i + 1, i + 3)
			break
print(a, b)


s = input()
t = s[1:] + ' '
r = s[2:] + '  '
for (n, (i, j, k)) in enumerate(zip(s, t, r)):
	if i == j:
		print(n + 1, n + 2)
		exit()
	elif i == k:
		print(n + 1, n + 3)
		exit()
print(-1, -1)


import sys
S = input()
L = len(S)
if S[0] == S[1]:
	print(1, 2)
	sys.exit()
if L == 2:
	print(-1, -1)
	sys.exit()
ansL = -1
ansR = -1
for i in range(2, L):
	if S[i - 1] == S[i]:
		ansL = i
		ansR = i + 1
		break
	if S[i - 2] == S[i]:
		ansL = i - 1
		ansR = i + 1
		break
print(ansL, ansR)


def solve():
	S = input()
	N = len(S)
	for i in range(N - 1):
		if S[i] == S[i + 1]:
			return (i + 1, i + 2)
		if i < N - 2 and S[i] == S[i + 2]:
			return (i + 1, i + 3)
	return (-1, -1)
print(*solve())


import sys
input = sys.stdin.readline

def main():
	s = input().strip()
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			print(i + 1, i + 2)
			return
		if i < len(s) - 2:
			if s[i] == s[i + 2]:
				print(i + 1, i + 3)
				return
	print(-1, -1)
main()


s = input()
if len(s) == 2 and s[0] == s[1]:
	print(1, 2)
else:
	for i in range(3, len(s) + 1):
		a = s[i - 3:i]
		if len(set(a)) != 3:
			print(i - 2, i)
			break
	else:
		print(-1, -1)


def solve(s):
	if len(s) == 2 and s[0] == s[1]:
		return (1, 2)
	for l in range(len(s) - 2):
		(a, b, c) = sorted(s[l:l + 3])
		if a == b or b == c:
			return (l + 1, l + 3)
	return (-1, -1)
print(*solve(input()))


入力 = input()
for i in range(len(入力) - 1):
	if 入力[i] == 入力[i + 1]:
		print(i + 1, i + 2)
		exit()
	elif i < len(入力) - 2 and 入力[i] == 入力[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = str(input())
n = len(s)
for i in range(1, n):
	if s[i] == s[i - 1]:
		print(i, i + 1)
		break
	elif i >= 2 and s[i] == s[i - 2]:
		print(i - 1, i + 1)
		break
else:
	print(-1, -1)


from collections import Counter
s = input()
for i in range(len(s) - 2):
	for v in Counter(s[i:i + 3]).values():
		if v >= 2:
			print(i + 1, i + 3)
			exit()
for i in range(len(s) - 1):
	for v in Counter(s[i:i + 2]).values():
		if v >= 2:
			print(i + 1, i + 2)
			exit()
print(-1, -1)


ss = input()
iChars = {}
for (i, s) in enumerate(ss, 1):
	iPrev = iChars.get(s, -2)
	if i - iPrev <= 2:
		print(iPrev, i)
		break
	iChars[s] = i
else:
	print('-1 -1')


import string
S = input()
N = len(S)
for i in range(N):
	if i < N - 1 and S[i] == S[i + 1]:
		print(i + 1, i + 2)
		quit()
	elif i < N - 2 and S[i] == S[i + 2]:
		print(i + 1, i + 3)
		quit()
print(-1, -1)


s = input()
if len(s) == 2:
	print(1, 2) if s[1] == s[0] else print(-1, -1)
else:
	for i in range(2, len(s)):
		if s[i] == s[i - 1]:
			print(i, i + 1)
		elif s[i] == s[i - 2]:
			print(i - 1, i + 1)
		else:
			continue
		break
	else:
		print(-1, -1)


def main():
	s = input().strip()
	if len(s) == 2:
		return '1 2' if s[0] == s[1] else '-1 -1'
	for i in range(len(s) - 2):
		if len(set(s[i:i + 3])) <= 2:
			return '{} {}'.format(i + 1, i + 3)
	return '-1 -1'
print(main())


s = input()
s += '?'
for i in range(len(s) - 2):
	if len(set(list(s[i:i + 3]))) < 3:
		if i == len(s) - 3:
			print(i + 1, i + 2)
		else:
			print(i + 1, i + 3)
		exit()
print(-1, -1)


from collections import Counter
s = input()
n = len(s)
ans = True
if n > 2:
	for i in range(n - 2):
		if max(list(Counter(s[i:i + 3]).values())) > 1:
			print(i + 1, i + 3)
			ans = False
			exit()
	if ans:
		print(-1, -1)
elif max(list(Counter(s).values())) > 1:
	print(1, 2)
else:
	print(-1, -1)


def main():
	s = input()
	for (i, (a, b)) in enumerate(zip(s, s[1:]), start=1):
		if a == b:
			print(i, i + 1)
			return
	for (i, (a, b)) in enumerate(zip(s, s[2:]), start=1):
		if a == b:
			print(i, i + 2)
			return
	print(-1, -1)
main()


s = input()
s_l = len(s)
for i in range(s_l - 1):
	if s[i] == s[i + 1]:
		i += 1
		print(i, i + 1)
		exit()
	elif i != s_l - 2 and s[i] == s[i + 2]:
		i += 1
		print(i, i + 2)
		exit()
print(-1, -1)


S = input()
N = len(S)
for i in range(N - 1):
	if S[i] == S[i + 1]:
		print(i + 1, i + 2)
		exit()
for i in range(N - 2):
	if S[i] == S[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


import sys
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
S = list(input())
N = len(S)
for i in range(1, N):
	if S[i - 1] == S[i]:
		print(i, i + 1)
		exit()
for i in range(2, N):
	if S[i - 2] == S[i]:
		print(i - 1, i + 1)
		exit()
print(-1, -1)


S = input()
for (i, (a, b)) in enumerate(zip(S, S[1:])):
	if a == b:
		print(i + 1, i + 2)
		exit()
for (i, (a, b)) in enumerate(zip(S, S[2:])):
	if a == b:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


S = input()
a = 0
for i in range(len(S) - 2):
	if S[i] == S[i + 1] or S[i] == S[i + 2] or S[i + 1] == S[i + 2]:
		a = 1
		print(i + 1, i + 3)
		break
if a == 0:
	if len(S) > 1 and S[-1] == S[-2]:
		print(len(S) - 1, len(S))
	else:
		print(-1, -1)


s = input()
(a, b) = (-1, -1)
if len(s) == 2 and s[0] == s[1]:
	(a, b) = (1, 2)
elif len(s) > 1:
	for i in range(len(s) - 2):
		if s[i] == s[i + 1]:
			(a, b) = (i + 1, i + 2)
			break
		if s[i] == s[i + 2]:
			(a, b) = (i + 1, i + 3)
			break
print(a, b)


s = input()
p2 = s[0]
p1 = s[1]
ans = '-1 -1'
if p2 == p1:
	ans = '1 2'
else:
	for i in range(2, len(s)):
		if p2 == s[i] or p1 == s[i]:
			ans = str(i - 1) + ' ' + str(i + 1)
			break
		p2 = s[i - 1]
		p1 = s[i]
print(ans)


def solve():
	s = input()
	len_s = len(s)
	for i in range(len_s - 1):
		c = s[i:i + 2]
		if c[0] == c[1]:
			print(i + 1, i + 2)
			exit()
	for i in range(len_s - 2):
		c = s[i:i + 3]
		if c[0] == c[-1]:
			print(i + 1, i + 3)
			exit()
	print(-1, -1)
solve()


from itertools import combinations as comb
s = input()
l = []
for i in comb(set(s), 2):
	(a, b) = i
	l.extend([a + b + a, b + a + b])
for i in set(s):
	l.extend([i + i])
for i in l:
	(a, b) = (i, len(i))
	c = s.find(a)
	if c != -1:
		print(c + 1, c + b)
		break
else:
	print(-1, -1)


S = str(input())
for k in range(len(S) - 1):
	if S[k] == S[k + 1]:
		print(k + 1, k + 2)
		exit()
for k in range(len(S) - 2):
	if S[k] == S[k + 2]:
		print(k + 1, k + 3)
		exit()
print(-1, -1)


s = input()
n = len(s)

def solve():
	for i in range(n - 1):
		if s[i] == s[i + 1]:
			return (i + 1, i + 2)
	for i in range(n - 2):
		if s[i] == s[i + 2]:
			return (i + 1, i + 3)
	return (-1, -1)
(a, b) = solve()
print(a, b)


import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline
S = list(input().strip())
for i in range(len(S) - 1):
	if S[i] == S[i + 1]:
		print(i + 1, i + 2)
		exit()
for i in range(len(S) - 2):
	if S[i] == S[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = input()
l = len(s)
for i in range(l - 2):
	temp = s[i]
	if s[i + 1] == temp:
		print(str(i + 1) + ' ' + str(i + 2))
		quit()
	if s[i + 2] == temp:
		print(str(i + 1) + ' ' + str(i + 3))
		quit()
if s[-1] == s[-2]:
	print(str(l - 1) + ' ' + str(l))
	quit()
print('-1 -1')


import sys
readline = sys.stdin.readline
S = readline().rstrip()
if len(S) == 2:
	if S[0] == S[1]:
		print(1, 2)
	else:
		print(-1, -1)
	exit(0)
for i in range(len(S) - 3):
	if len(set(S[i:i + 3])) < 3:
		print(i + 1, i + 3)
		exit(0)
else:
	print(-1, -1)


import sys

def main():
	s = input()
	l = len(s)
	for i in range(l - 1):
		if s[i] == s[i + 1]:
			print(i + 1, i + 2)
			exit()
	for i in range(l - 2):
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			exit()
	print(-1, -1)
main()


def main():
	s = input()
	if len(s) == 2 and s[0] == s[1]:
		print(1, 2)
		return
	for i in range(len(s) - 2):
		if s[i] == s[i + 1] or s[i + 1] == s[i + 2] or s[i] == s[i + 2]:
			print(i + 1, i + 3)
			return
	print(-1, -1)
	return
main()


a = input()
n = len(a)
ansa = -1
ansb = -1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		ansa = i
for j in range(n - 2):
	if a[j] == a[j + 2]:
		ansb = j
if ansa != -1:
	print(ansa + 1, ansa + 2)
elif ansb != -1:
	print(ansb + 1, ansb + 3)
else:
	print(-1, -1)


s = input()
for i in range(len(s) - 2):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		break
	elif s[i] == s[i + 2]:
		print(i + 1, i + 3)
		break
else:
	if len(s) == 2 and s[0] == s[1]:
		print(1, 2)
	else:
		print('-1 -1')


s = input()
ans = (-1, -1)
if s[0] == s[1]:
	ans = (1, 2)
for i in range(len(s) - 2):
	if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
		ans = (i + 1, i + 3)
print(ans[0], ans[1])


s = input()

def c(a):
	return ord(a) - ord('a')
d = [-100] * 26
for (i, v) in enumerate(s):
	if i - d[c(v)] <= 1:
		print(i, i + 1)
		exit()
	elif i - d[c(v)] <= 2:
		print(i - 1, i + 1)
		exit()
	d[c(v)] = i
print(-1, -1)


s = input()
a = -1
at = -1
b = -1
bt = -1
for i in range(len(s)):
	if a == s[i]:
		print(at + 1, i + 1)
		quit()
	if b == s[i]:
		print(bt + 1, i + 1)
		quit()
	a = b
	at = bt
	b = s[i]
	bt = i
print(-1, -1)


import re
repatter = re.compile('([a-z]).?\\1')
s = input()
matchObj = repatter.search(s)
if matchObj:
	print(matchObj.start() + 1, matchObj.end())
else:
	print(-1, -1)


def judge(str):
	for i in range(len(str) - 2):
		if str[i] == str[i + 2]:
			print(i + 1, i + 3)
			return
	for i in range(len(str) - 1):
		if str[i] == str[i + 1]:
			print(i + 1, i + 2)
			return
	print(-1, -1)
	return
s = input()
judge(s)


def main():
	s = input()
	ans = ['-1', '-1']
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			ans = [str(i + 1), str(i + 2)]
			break
		if i == len(s) - 2:
			break
		if s[i] == s[i + 2]:
			ans = [str(i + 1), str(i + 3)]
			break
	print(' '.join(ans))
main()


a = input()
flag = 0
for i in range(len(a) - 1):
	if flag == 0:
		if a[i] == a[i + 1]:
			print('{0} {1}'.format(i + 1, i + 2))
			flag = 1
		elif i + 2 != len(a) and a[i] == a[i + 2]:
			print('{0} {1}'.format(i + 1, i + 3))
			flag = 1
if flag == 0:
	print('-1 -1')


s = input()
n = len(s)
x = [ord(c) - ord('a') for c in s]
for i in range(1, n):
	if x[i] == x[i - 1]:
		print('{} {}'.format(i, i + 1))
		exit(0)
	if i > 1 and x[i - 2] == x[i]:
		print('{} {}'.format(i - 1, i + 1))
		exit(0)
print('-1 -1')


s = input()
n = len(s)
for i in range(n - 1):
	if i < n - 2:
		if s[i] == s[i + 1]:
			print(i + 1, i + 2)
			break
		elif s[i] == s[i + 2]:
			print(i + 1, i + 3)
			break
		else:
			continue
	elif s[i] == s[i + 1]:
		print(i + 1, i + 2)
	else:
		print(-1, -1)


import itertools
S = input()
l = len(S)
if l == 2:
	if S[0] == S[1]:
		print(1, 2)
	else:
		print(-1, -1)
	exit()
else:
	for i in range(l - 2):
		(a, b, c) = (S[i], S[i + 1], S[i + 2])
		if a == b or b == c or a == c:
			print(i + 1, i + 3)
			exit()
print(-1, -1)


a = input()
count = 0
if len(a) > 3:
	for i in range(len(a) - 2):
		if a[i] == a[i + 1] or a[i] == a[i + 2] or a[i + 1] == a[i + 2]:
			print(i + 1, i + 3)
			count += 1
			break
elif a[0] == a[1]:
	print(1, 2)
	count += 1
if count == 0:
	print(-1, -1)


s = list(input())
ans = [-1, -1]
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		ans = [i + 1, i + 2]
		break
	if i < len(s) - 2 and s[i] == s[i + 2]:
		ans = [i + 1, i + 3]
print(ans[0], ans[1])


def solve():
	S = input()
	n = len(S)
	if S[0] == S[1]:
		return [1, 2]
	for i in range(1, n):
		if S[i] == S[i - 1]:
			return [i, i + 1]
		if i >= 2 and S[i] == S[i - 2]:
			return [i - 1, i + 1]
	return [-1, -1]
print(*solve())


import sys

def input():
	return sys.stdin.readline()[:-1]
s = input()
for i in range(len(s) - 2):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		break
	elif s[i] == s[i + 2]:
		print(i + 1, i + 3)
		break
else:
	if len(s) == 2 and s[0] == s[1]:
		print(1, 2)
	else:
		print('-1 -1')


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
s = readline().rstrip().decode()
if s[0] == s[1]:
	print(1, 2)
	exit()
for (i, (af, s, bf)) in enumerate(zip(s, s[1:], s[2:])):
	if af == s or af == bf or s == bf:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = input()
bb = ''
b = ''
ans = -1
end = -1
for i in range(len(s)):
	if s[i] == b:
		ans = i
		end = i + 1
		break
	elif s[i] == bb:
		ans = i - 1
		end = i + 1
		break
	else:
		bb = b
		b = s[i]
print(ans, end)


S = str(input())
left = -2
right = -2
for i in range(max(1, len(S) - 2)):
	if S[i] == S[i + 1]:
		left = i
		right = i + 1
		break
	if len(S) == 2:
		break
	if S[i] == S[i + 2]:
		left = i
		right = i + 2
		break
	if S[i + 1] == S[i + 2]:
		left = i + 1
		right = i + 2
		break
print(left + 1, right + 1)


S = input()
N = len(S)
for i in range(N - 1):
	if S[i] == S[i + 1]:
		print(i + 1, i + 2)
		break
else:
	for i in range(N - 2):
		if S[i] == S[i + 2]:
			print(i + 1, i + 3)
			break
	else:
		print(-1, -1)


import string
S = input()
for a in string.ascii_lowercase:
	pre = -1
	for (i, s) in enumerate(S):
		if s == a:
			if pre != -1 and i - pre <= 2:
				print(pre + 1, i + 1)
				exit()
			else:
				pre = i
print(-1, -1)


S = input()
for i in range(len(S) - 1):
	(a, b) = (S[i], S[i + 1])
	if a == b:
		print(i + 1, i + 2)
		exit()
for i in range(len(S) - 2):
	(a, b) = (S[i], S[i + 2])
	if a == b:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


S = input()
c = {}
for i in [chr(ord('a') + i) for i in range(26)]:
	c[i] = 0
for i in range(len(S)):
	if i < 3:
		c[S[i]] += 1
		if c[S[i]] >= 2:
			print(1, i + 1)
			exit()
	else:
		c[S[i - 3]] -= 1
		c[S[i]] += 1
		if c[S[i]] >= 2:
			print(i - 1, i + 1)
			exit()
print(-1, -1)


s = list(input())
N = len(s)
judge = 'balanced'
for i in range(N - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		judge = 'unbalanced'
		break
if judge == 'balanced':
	for i in range(N - 2):
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			judge = 'unbalanced'
			break
if judge == 'balanced':
	print(-1, -1)


s = input()
n = len(s)
ans = (-1, -1)
for i in range(n - 1):
	if s[i] == s[i + 1]:
		ans = [i + 1, i + 2]
	elif i < n - 2 and s[i] == s[i + 2]:
		ans = [i + 1, i + 3]
print(ans[0], ans[1])


S = input()
if S[0] == S[1]:
	print(1, 2)
	exit()
L = [S[0], S[1]]
for i in range(2, len(S)):
	s = S[i]
	if s in L:
		print(i + 1 - (2 - L.index(s)), i + 1)
		exit()
	else:
		L.pop(0)
		L.append(s)
print(-1, -1)


s = input()
pp = s[0]
p = s[1]
for i in range(len(s) - 2):
	c = s[i + 2]
	if pp == p:
		print(i + 1, i + 2)
		break
	elif p == c:
		print(i + 2, i + 3)
		break
	elif pp == c:
		print(i + 1, i + 3)
		break
	(p, pp) = (c, p)
else:
	if s[0] == s[1]:
		print(1, 2)
	else:
		print(-1, -1)


s = input()
N = len(s)
flag = 0
if N == 2:
	if s[0] == s[1]:
		print(*[1, 2])
	else:
		print(*[-1, -1])
else:
	for i in range(N - 2):
		if s[i] == s[i + 1] or s[i + 1] == s[i + 2] or s[i] == s[i + 2]:
			print(*[i + 1, i + 3])
			flag = 1
			break
	if flag == 0:
		print(*[-1, -1])


s = input()
length = len(s)
ans = '-1 -1'
for i in range(length - 1):
	if s[i] == s[i + 1]:
		ans = '{} {}'.format(i + 1, i + 2)
		break
	if i < length - 2 and s[i] == s[i + 2]:
		ans = '{} {}'.format(i + 1, i + 3)
		break
print(ans)


s = input()
n = len(s)
for k in range(1, n):
	if s[k - 1] == s[k]:
		print(k, k + 1)
		exit(0)
for k in range(1, n - 1):
	if s[k - 1] == s[k + 1]:
		print(k, k + 2)
		exit(0)
print(-1, -1)


s = list(input())
n = len(s)
start = -1
end = -1
if n == 2:
	if s[0] == s[-1]:
		start = 1
		end = 2
for i in range(n - 2):
	a = [0] * 26
	for j in range(3):
		a[ord(s[i + j]) - ord('a')] += 1
	if max(a) >= 2:
		ans = 1
		start = i + 1
		end = i + 3
		break
print(start, end)


S = list(input())
S.append('A')
for j in range(len(S) - 2):
	if S[j] == S[j + 1]:
		print(j + 1, j + 2)
		exit()
	if S[j] == S[j + 2]:
		print(j + 1, j + 3)
		exit()
else:
	print('-1 -1')


import collections
A = input()
for i in range(len(A) - 1):
	B = A[i:i + 2]
	C = collections.Counter(B)
	if C.most_common()[0][1] == 2:
		print(i + 1, i + 2)
		exit()
for i in range(len(A) - 2):
	B = A[i:i + 3]
	C = collections.Counter(B)
	if C.most_common()[0][1] == 2:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


sn = input()
for i in range(len(sn) - 1):
	if sn[i] == sn[i + 1]:
		print(i + 1, i + 2)
		break
	if i < len(sn) - 2 and sn[i] == sn[i + 2]:
		print(i + 1, i + 3)
		break
else:
	print(-1, -1)


s = input()
n = len(s)
(A, B) = (-1, -1)
for i in range(n - 1):
	if s[i] == s[i + 1]:
		(A, B) = (i + 1, i + 2)
for i in range(n - 2):
	if s[i] == s[i + 2]:
		(A, B) = (i + 1, i + 3)
print(A, B)


S = input()
N = len(S)

def sol():
	for i in range(N - 1):
		T = list(S[i:i + 2])
		if len(set(T)) == 1:
			return (i + 1, i + 2)
	for i in range(N - 2):
		T = list(S[i:i + 3])
		if len(set(T)) <= 2:
			return (i + 1, i + 3)
	return (-1, -1)
print(*sol())


s = input()
k = -1
l = -1
flag = False
for i in range(0, len(s) - 1):
	if s[i] == s[i + 1]:
		flag = True
		k = i + 1
		l = i + 2
		break
if not flag:
	if len(s) > 2:
		for j in range(0, len(s) - 2):
			if s[j] == s[j + 2]:
				flag = True
				k = j + 1
				l = j + 3
				break
	else:
		None
print(k, l)


import sys
s = sys.stdin.readline().rstrip()
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		sys.exit()
for i in range(len(s) - 2):
	if s[i] == s[i + 2]:
		print(i + 1, i + 3)
		sys.exit()
print(-1, -1)


S = input()
one = S[0]
two = S[1]
ans = '-1 -1'
l = len(S)
for i in range(2, l):
	s = S[i]
	if s == one:
		ans = str(i - 1) + ' ' + str(i + 1)
		break
	elif s == two:
		ans = str(i) + ' ' + str(i + 1)
		break
	(one, two) = (two, s)
if l == 2:
	if one == two:
		ans = '1 2'
print(ans)


s = input()
for (i, c) in enumerate(s):
	if i == 0:
		continue
	if i == 1:
		if s[i - 1] == s[i]:
			print(i, i + 1)
			break
		continue
	if s[i - 1] == s[i]:
		print(i, i + 1)
		break
	if s[i - 2] == s[i]:
		print(i - 1, i + 1)
		break
else:
	print(-1, -1)


s = input()
flag = 0
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		flag = 1
		break
	if i < len(s) - 2:
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			flag = 1
			break
if flag == 0:
	print(-1, -1)


import sys
S = input()
left = 0
right = 0
for i in range(len(S) - 1):
	if S[i] == S[i + 1]:
		left = i + 1
		right = left + 1
		break
for i in range(len(S) - 2):
	if S[i] == S[i + 2]:
		left = i + 1
		right = left + 2
		break
if left == right:
	print(-1, -1)
else:
	print(left, right)


s = input()
n = len(s)
res = -1
leng = 0
for i in range(n - 2):
	if s[i] == s[i + 1]:
		res = i + 1
		leng = 2
		break
	elif s[i] == s[i + 2]:
		res = i + 1
		leng = 3
		break
if s[-2] == s[-1]:
	res = n - 1
	leng = 2
if res == -1:
	print('-1 -1')
elif leng == 2:
	print(str(res) + ' ' + str(res + 1))
else:
	print(str(res) + ' ' + str(res + 2))


s = list(input())
for i in range(26):
	x = chr(i + ord('a'))
	cnt = 0
	m = (0, -1)
	for (j, t) in enumerate(s):
		cnt -= 1
		if t == x:
			cnt += 2
		if m[0] < cnt and m[1] + 1 != j:
			print(m[1] + 2, j + 1)
			exit(0)
		elif m[0] > cnt:
			m = (cnt, j)
print(-1, -1)


s = input()
n = len(s)
(pre2, pre1) = (0, 0)
if n == 2 and s[0] == s[1]:
	print(1, 2)
	exit()
for j in range(n):
	i = s[j]
	if i == pre2 or i == pre1:
		print(j - 1, j + 1)
		exit()
	else:
		pre2 = pre1
		pre1 = i
else:
	print('-1 -1')


S = input()
bef0 = (1, S[0])
bef1 = (2, S[1])
if bef0[1] == bef1[1]:
	print('1 2')
	exit()
else:
	flag = True
	for i in range(2, len(S)):
		if bef0[1] == S[i] or bef1[1] == S[i]:
			print(' '.join([str(bef0[0]), str(i + 1)]))
			flag = False
			break
		else:
			bef0 = bef1
			bef1 = (i + 1, S[i])
	if flag:
		print('-1 -1')


s = input()
d = dict()
for i in range(len(s)):
	c = s[i]
	if d.__contains__(c):
		d[c].append(i)
	else:
		d[c] = []
		d[c].append(i)
for c in d.keys():
	for i in range(len(d[c]) - 1):
		if d[c][i + 1] - d[c][i] < 3:
			print(d[c][i] + 1, d[c][i + 1] + 1)
			exit(0)
print(-1, -1)


S = input()
N = len(S)
if N == 2 and S[0] == S[1]:
	print(1, 2)
	exit()
for i in range(N - 2):
	if len(set(S[i:i + 3])) == 3:
		pass
	else:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)
S = input()
for i in range(len(S)):
	if i <= len(S) - 2:
		if S[i] == S[i + 1]:
			print('{} {}'.format(i + 1, i + 2))
			break
	if i <= len(S) - 3:
		if S[i] == S[i + 2]:
			print('{} {}'.format(i + 1, i + 3))
			break
else:
	print('-1 -1')


s = input()
l = len(s)
s += '123'
for i in range(l):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		exit()
	elif s[i] == s[i + 2]:
		print(i + 1, i + 3)
		exit()
print(-1, -1)


s = input()
p1 = s[0]
p2 = s[1]
if p1 == p2:
	print(1, 2)
else:
	flag = True
	for i in range(2, len(s)):
		if p1 == s[i]:
			print(i - 1, i + 1)
			flag = False
			break
		elif p2 == s[i]:
			print(i, i + 1)
			flag = False
			break
		p1 = s[i - 1]
		p2 = s[i]
	if flag:
		print(-1, -1)


s = input()
n = len(s)
if n == 2:
	if s[0] == s[1]:
		print(1, 2)
	else:
		print(-1, -1)
else:
	s = '!!' + s
	f = False
	for i in range(n):
		if s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
			f = True
			print(i - 1, i + 1)
			break
	if not f:
		print(-1, -1)


r = '-1 -1'
s = input()
for i in range(len(s) - 2):
	if len(set(s[i:i + 3])) <= 2:
		r = str(i + 1) + ' ' + str(i + 3)
		break
if len(s) == 2 and len(set(list(s))) == 1:
	r = '1 2'
print(r)


def main():
	s = input()
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			print('{} {}'.format(i + 1, i + 2))
			return
		elif i + 2 < len(s) and s[i] == s[i + 2]:
			print('{} {}'.format(i + 1, i + 3))
			return
	print('-1 -1')
	return
main()


s = input()
result = [-1, -1]
for i in range(len(s) - 2):
	x = s[i:i + 3]
	if x[0] == x[1] or x[0] == x[2] or x[1] == x[2]:
		result = [i + 1, i + 3]
		break
if len(s) == 2 and s[0] == s[1]:
	result = [1, 2]
print(*result)


s = input()
l = len(s)
for i in range(l - 1):
	if s[i] == s[i + 1]:
		print(str(i + 1) + ' ' + str(i + 2))
		exit(0)
	elif i != l - 2:
		if s[i] == s[i + 2]:
			print(str(i + 1) + ' ' + str(i + 3))
			exit(0)
print('-1 -1')


s = input()
u = len(s)
a = s[0]
b = s[1]
if u == 2 or a == b:
	print('1 2' if a == b else '-1 -1')
	exit(0)
for i in range(2, u):
	c = s[i]
	if a == c:
		print('{} {}'.format(i - 1, i + 1))
		exit(0)
	if b == c:
		print('{} {}'.format(i, i + 1))
		exit(0)
	a = b
	b = c
print('-1 -1')


from collections import Counter
s = input()
possible = 0
for i in range(len(s) - 2):
	if len(Counter(s[i:i + 3])) < 3:
		print(i + 1, i + 3)
		possible = 1
		break
if len(s) == 2:
	if s[0] == s[1]:
		print(1, 2)
		possible = 1
if not possible:
	print(-1, -1)


from collections import defaultdict
s = list(input())
d = defaultdict(list)
for i in range(len(s)):
	if d[s[i]]:
		ld = i - d[s[i]][-1]
		if ld <= 2:
			print(i - ld + 1, i + 1)
			break
	d[s[i]].append(i)
else:
	print(-1, -1)


s = list(input())
n = len(s)
if n < 3:
	print(*([1, 2] if len(set(s)) < 2 else [-1, -1]))
	exit()
ans = (-1, -1)
for i in range(1, n - 1):
	if len(set(s[i] + s[i - 1] + s[i + 1])) < 3:
		ans = (i, i + 2)
		break
print(*ans)


s = list(input())
N = len(s)
for i in range(N - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		exit()
if N >= 3:
	for i in range(N - 2):
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			exit()
print('-1 -1')


d = {}
for (i, c) in enumerate(input(), 1):
	if c in d and i - d[c] <= 2:
		print(d[c], i)
		break
	d[c] = i
else:
	print(-1, -1)


S = input()
if len(S) == 2:
	if S[0] == S[1]:
		print(1, 2)
	else:
		print(-1, -1)
else:
	ans = [-1, -1]
	for (ind, s) in enumerate(S[:-2]):
		if s == S[ind + 1]:
			ans = [ind + 1, ind + 2]
			break
		elif s == S[ind + 2]:
			ans = [ind + 1, ind + 3]
			break
	print(*ans)


def main():
	S = input()
	for (i, (a, b)) in enumerate(zip(S, S[1:]), start=1):
		if a == b:
			print(i, i + 1)
			return
	for (i, (a, b, c)) in enumerate(zip(S, S[1:], S[2:]), start=1):
		if a == c:
			print(i, i + 2)
			return
	print(-1, -1)
main()


s = list(input())
n = len(s)
if n == 2:
	if s[0] == s[1]:
		print(1, 2)
	else:
		print(-1, -1)
else:
	for i in range(n - 2):
		if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
			print(i + 1, i + 3)
			exit()
	print(-1, -1)


s = input()
ans = ''
for i in range(len(s) - 1):
	if s[i] == s[i + 1]:
		ans = ' '.join([str(i + 1), str(i + 2)])
for j in range(len(s) - 2):
	if s[j] == s[j + 2]:
		ans = ' '.join([str(j + 1), str(j + 3)])
if ans:
	print(ans)
else:
	print('-1 -1')