Time limit
1s
Memory limit
128 MB
N rotatable number dials are connected vertically. The top dial is dial 1, and the bottom dial is dial N. Each dial has ten faces labeled 0, 1, 2, ..., 9 in order toward the right.
If you rotate a dial to the left, that dial and every dial below it rotate together. If you rotate a dial to the right, only that dial rotates.
Given the current state and the target state read from top to bottom from the front, output a sequence of rotations that reaches the target state with the minimum total number of rotation steps.

The first line contains the number of dials N. The second line contains a digit string of length N representing the current state, and the third line contains a digit string of length N representing the target state.
N is between 3 and 10,000, inclusive.
On the first line, output the minimum number of rotation steps needed to reach the target state. Starting on the next line, output one rotation per line in execution order: the dial number and the number of steps, separated by a space.
Use positive numbers for left rotations. Output 4 for a left rotation by 4 steps, and -3 for a right rotation by 3 steps. If there are multiple valid answers, output any one of them.