A number is called stepping number if all adjacent digits have an absolute difference of 1, e.g. '321' is a Stepping Number while 421 is not. Given two integers n and m, find the count of all the stepping numbers in range [n, m].

**Examples:**

**Input :** n = 0, m = 21
**Output :** 13
Stepping no's are 0 1 2 3 4 5 6 7 8 9 10 12 21
**Input :** n = 10, m = 15
**Output :** 2
Stepping no's are 10, 12

**Input:**

The first line of the input contains an integer T, denoting the number of test cases. Then T test case follows. The only line of each test case contains two space separated integers denoting the values of n and m respectively.

**Output:**

For each test case in a new line print an integer denoting the number of stepping numbers in the range between n and m.

**Constraints:**

1<=T<=10^{2}

0<=N,M<=10^6

**Example:
Input:**

3

0 21

10 15

0 1

13

2

2

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

tushki | 198 |

namansharmacse17 | 110 |

TusharMittal3 | 70 |

adkeaesph | 57 |

deepakchoudhary11 | 48 |

ARUN_PUNDIR | 720 |

manishgupta8497 | 623 |

AMAN__JAIN | 596 |

Abhimanyu_kumar | 562 |

Bicky_Shokeen | 532 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.