BALNUM - Balanced Numbers

题意翻译

一个数被称为是平衡的数,当且仅当对于所有出现过的数位(即 $0-9$ ),每个偶数出现奇数次,每个奇数出现偶数次。给定 $A,B$,请统计出 $[A,B]$ 内所有平衡数的个数。 $1\leq A\leq B\leq 10^{19}$

题目描述

Balanced numbers have been used by mathematicians for centuries. A positive integer is considered a balanced number if: 1\) Every **even** digit appears an **odd** number of times in its decimal representation 2\) Every **odd** digit appears an **even** number of times in its decimal representation For example, 77, 211, 6222 and 112334445555677 are balanced numbers while 351, 21, and 662 are not. Given an interval \[A, B\], your task is to find the amount of balanced numbers in \[A, B\] where both **A and B are included.**

输入输出格式

输入格式


The first line contains an integer T representing the number of test cases. A test case consists of two numbers A and B separated by a single space representing the interval. You may assume that 1 <= A <= B <= 10 $ ^{19} $

输出格式


For each test case, you need to write a number in a single line: the amount of balanced numbers in the corresponding interval

输入输出样例

输入样例 #1

2
1 1000
1 9

输出样例 #1

147
4