Count pairs where , , and has some property. This is 2D digit DP. Build and simultaneously, digit by digit.
State: . The carry matters: when checking if has no digit > 5, you need to know if there's a carry from previous positions. Complexity explodes: . Use only when necessary.