P15294 [ROI 2012 Day 1] password

Background

Translation source: [loj #5455. 「ROI 2012 Day 1」password](https://loj.ac/p/5455).

Description

An Olympiad contestant is studying a program used to encrypt login passwords for a system. After running, the program outputs two natural numbers. The second number is obtained from the first number by replacing some non-empty contiguous block of digits with the sum of those digits. It is known that the password is exactly the block of digits in the first number that was replaced by the corresponding sum in the second number. You need to write a program that, given these two numbers, determines the starting and ending positions of the block of digits that forms the password.

Input Format

The input file contains two lines. The first line is the first number, containing no more than $10^5$ digits. The second line is the second number. It is guaranteed that neither number has leading zeros.

Output Format

The output file should contain two integers separated by a space, representing the starting position and ending position of the replaced block of digits in the first number. If there are multiple solutions, you may output any one of them. It is guaranteed that at least one solution exists.

Explanation/Hint

In the first sample, the digit block $148$ is replaced by $13$ (that is, $1 + 4 + 8 = 13$). The detailed additional constraints and scores for the subtasks are shown in the table below: | Subtask | Score | Additional Constraints | | :-----: | :---: | :--------------------: | | $1$ | $30$ | The first number is less than $10^{9}$. | | $2$ | $30$ | The first number is less than $10^{1000}$. | | $3$ | $40$ | The first number is less than $10^{100000}$. | Translated by ChatGPT 5