A Plus B Problem
시간 제한3초메모리 제한1024 MB
두 개의 n자리 수를 더한 결과가 세 번째 행에 있고, 첫 두 행의 한 자리를 바꾸는 질의마다 합의 해당 자리와 이번 갱신으로 값이 바뀐 전체 자릿수를 구한다.
문제
JB gets a machine that can solve "A Plus B Problem" and feels curious about the mechanism. He hears that you are proficient in competitive programming and have learned many advanced data structures and algorithms such as Link-Cut tree, Lagrange Inversion formula, Sweepline Mo, and so on. Hence, he asks you to help implement a program that can solve "A Plus B Problem" as same as the machine.
The machine consists of digits. The digits of the first two rows can be changed arbitrarily, and the third row always equals the decimal sum of the first two rows. The third row only consists of the lowest digits even if the sum exceeds digits.
For example, when , the three rows can be "01234", "56789", "58023" or "56789", "58023", "14812".
To test your function, you are given queries. In the -th query, the -th digit of the -th row is updated to (the digit may not change). Because the digits are too many and JB has no time to check your answer, he only asks you to find the -th digit of the third row after the query and how many digits of the machine change in the query.
입력
The first line contains two integers and ().
The second line contains a string consisting of digits, representing the first row of the machine.
The third line contains a string consisting of digits, representing the second row of the machine.
There are lines in the following. The -th of the following line consists of three integers and (, , ).
출력
Output lines. In the -th line, output two integers - the -th digit of the third row after the query and how many digits of the machine change in the query.
힌트
In the example, the initial rows are "01234", "56789", "58023".
After the -st query, the rows are "01234", "06789", "08023".
After the -nd query, the rows are "01234", "01789", "03023".
After the -th query, the rows are "01234", "01289", "02523".
After the -th query, the rows are "01234", "01239", "02473".
After the -th query, the rows are "01234", "01234", "02468".