Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/string-harf-orinlari

First and last position of a letter

Easy 1000 ms 64 MB 22%
Share

A string $s$ and a letter $c$ are given. At which positions does $c$ occur in $s$ for the first and for the last time? Positions are numbered from $1$. If the letter occurs once, both numbers are the same; if it does not occur at all, print $-1$.

The letters of the string with their positions; the first and last occurrences of the given letter are highlighted

Input

The first line contains the string $s$, the second line a single letter $c$.

Output

Two space-separated integers or $-1$.

Note

$1 \le |s| \le 10^{5}$
$s$ and $c$ consist of lowercase Latin letters

Examples

Input #1
algoritm
o
Output #1
4 4
Input #2
salom
z
Output #2
-1

Sign in to submit a solution

Signing up is free and takes a minute.