P14471 [HackerEarth] Given two binary strings A and B, count how many cyclic permutations of B when taken XOR with A give 0.
普及
题目描述

Given two binary strings A and B, count how many cyclic permutations of B when taken XOR with A give 0.

Input
First line contains T, the number of testcases. Each testcase consists of two lines, first line contains A and next line contains B.

Output
For each testcase, print required answer in one line.

Constraints
1 ≤ T ≤ 10
1 ≤ length(A) = length(B) ≤ 10^5

SAMPLE INPUT
2
101
101
111
111

SAMPLE OUTPUT
1
3

Explanation

Testcase 1:
Three cyclic permutations of string B are 101, 110, 011.
Only one of them gives 0 when taken XOR with A.

Testcase 2:
Three cyclic permutations of string B are 111, 111, 111.
All of them gives 0 when taken XOR with A.

输入格式

见题面

输出格式

见题面

样例输入
10 1111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111 1111111111111111111111111111 1111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111 111111111111111111 111111111111111111 11111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111
样例输出
0 0 1 1 0 1 0 0 10 0