Two natural numbers n and m form a nice pair when the following holds.
- Cutting some digits off the back of n and placing them, in the same order, in front of what is left gives m.
For example, cutting 345 off the back of 12345 and placing it in front gives 34512, so (12345,34512) is a nice pair.
You are given two natural numbers A and B with the same number of digits. Count the pairs (x,y) with A≤x<y≤B such that (x,y) is a nice pair.
Two different cut lengths can produce the same m. In that case the pair (x,y) is counted once.