#B3990. Substring Match Pairs

    ID: 11647 Type: Default 1000ms 256MiB

Substring Match Pairs

Substring Match Pairs

Given two strings \(s\) and \(t\), we define \(s(l, r)\) to be the substring of \(s\) from its \(l\)th character to its \(r\)th character (inclusive), where \(1 \leq l \leq r \leq |s|\). For example, if \(s = \texttt{luogu}\), then \(s(2,4) = \texttt{uog}\).

Your task is to find all pairs \((l, r)\) such that the substring \(s(l, r)\) exactly matches \(t\).

inputFormat

The input consists of two lines:

  • The first line contains the string \(s\).
  • The second line contains the string \(t\).

outputFormat

If there exists at least one pair \((l, r)\) such that \(s(l, r) = t\), output each pair on a separate line with two space-separated integers \(l\) and \(r\) (using 1-indexing). If no such pair exists, print -1.

sample

luogu
uog
2 4