405424: GYM101955 I Distance Between Sweethearts
Description
Recently, my little sweetheart started to ignore me again. I was not sure this time if it's thanks to the agony of a long-distance relationship. So I flew to her city. Nothing changed. Alright, I bet you pray to God that even though you ignore me I still love you. But this seems like strange reasoning to me, as relationships are hard enough even without a $$$16000$$$-mile gap between you and me.
As Stephanie Coontz put in her book 'Marriage, a History':
She argues that the historical shift in emphasis to romantic love is related to the decline of religion, the precariousness of work situations, and the tendency of people to move about geographically rather than remaining in one place. However, an inevitable tension here exists because we are also living in a time which emphasises individuality, autonomy and reaching our personal goals. This means that old rules around rigid gender roles in relationships no longer apply. As sociologists put it:
Back to my personal question, I quantize the individualities, autonomies and personal goals for my little sweetheart and myself to non-negative integers, denoted by $$$I_{girl}, A_{girl}, G_{girl}$$$ and $$$I_{boy}, A_{boy}, G_{boy}$$$ respectively. A brilliant mathematical model that will save my love gives the following formula to measure the distance between the heart of my little sweetheart and mine:
$$$$$$distance(boy, girl) = \max\{|I_{boy} - I_{girl}|, |A_{boy} - A_{girl}|, |G_{boy} - G_{girl}|\} \oplus I_{boy} \oplus A_{boy} \oplus G_{boy} \oplus I_{girl} \oplus A_{girl} \oplus G_{girl},$$$$$$
where $$$\max\{S\}$$$, $$$|x|$$$ and $$$\oplus$$$ correspond to the maximum value in $$$S$$$, the absolute value of $$$x$$$ and the bitwise exclusive-OR operator respectively.
Sadly, it is hard to get these precise values and what I have now are their upper bounds. That is to say, they satisfy the following restrictions:
$$$$$$0 \le I_{girl} \le UI_{girl}, 0 \le A_{girl} \le UA_{girl}, 0 \le G_{girl} \le UG_{girl}$$$$$$
and
$$$$$$0 \le I_{boy} \le UI_{boy}, 0 \le A_{boy} \le UA_{boy}, 0 \le G_{boy} \le UG_{boy}.$$$$$$
Any value of them can be all integers in its restriction with the same probability. Now I need your help to calculate the expected distance between the hearts of the still amorous couple that we are. Please feedback the product between $$$(1 + UI_{boy}) (1 + UA_{boy}) (1 + UG_{boy}) (1 + UI_{girl}) (1 + UA_{girl}) (1 + UG_{girl})$$$ and the expected distance (which must be an integer).
InputThe input contains several test cases, and the first line contains a positive integer $$$T$$$ indicating the number of test cases which is up to $$$10$$$.
For each test case, the only line contains six integers $$$UI_{boy}, UA_{boy}, UG_{boy}$$$ and $$$UI_{girl}, UA_{girl}, UG_{girl}$$$, each of which is a non-negative integer up to $$$2000$$$.
OutputFor each test case, output a line containing "Case #x: y" (without quotes), where x is the test case number starting from $$$1$$$, and y is the answer to this test case.
We guarantee that all answers are no more than $$$(2^{64} - 1)$$$.
ExampleInput3Output
3 1 2 4 3 3
1 2 1 2 1 3
3 2 5 4 3 5
Case #1: 3880Note
Case #2: 369
Case #3: 24728
'Marriage, a History' is the one book you need to understand not only the nuances of modern marriage but also gay marriage, "living together" and divorce. Stephanie Coontz shatters dozens of myths about the past and future of married life and shows us why marriage, though more fragile today, can be more rewarding than ever before.
– from the inside of the book jacket