9617: Miscalculated Triangles

内存限制:512 MB 时间限制:4 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

In his homework, Sean ran into this problem:

--- How many different shapes of triangles are there in a 2D-plane, with lengths of its sides in {1,2,,s} and perimeter no longer than l ? Two triangles are considered to be in the same shape if they can completely overlap using only translation and rotation. Note that flips are not allowed. So for ΔABC and ΔABC (A,B,C and A,B,C are listed anti-clockwise.), if AB=2,BC=3,CA=4 and AB=2,AC=4,CA=3, they are not considered to be in the same shape.

Sean likes to consider problems in the binary system, so he uses the binary representation of numbers. He iterated over all possible (a,b,c) trying to find the answer, so what he wanted is the number of triplets (a,b,c) such that:

  • 1a,b,cs and are all integers.
  • a+b>c,a+c>b,b+c>a
  • a+b+cl

Then, he chose from these triplets such that each triplet chosen represents a different triangle. However, Sean was so bad at math that when he calculated a+b+c , he totally forgot about the carries, and therefore got the result of abc, which is the bitwise exclusive OR (XOR) sum of a,b and c .

Despite this mistake, Sean wants to know if he makes other mistakes, so he asks you about the answer if the third condition is abcl rather than a+b+cl. Can you help him out with this?

Since the answer can be enormous, output it modulo 998 244 353 .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases T (1T104) .
Each test case consists of a single line. The line contains 2 strings sl,ss (sl105,ss105) , the binary representation of the integers lll and s . It is guaranteed that l>0 and s>0, and the first character of string ss and sl is always 1 .
It is guaranteed that sl over all test cases in one test will not exceed 5×105 and ss over all test cases in one test will not exceed 5×105.

输出格式

For each test case, output 1 integer: the number of triangles in different shapes modulo 998 244 353 .

输入样例 复制

2
101 1111
1111 101

输出样例 复制

267
25