CF2204C.Spring

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Spring

Alice, Bob, and Carol visit a spring to collect water. Alice visits every aa days (on days a,2a,3a,a, 2a, 3a, \dots), Bob visits every bb days (on days b,2b,3b,b, 2b, 3b, \dots), and Carol visits every cc days (on days c,2c,3c,c, 2c, 3c, \dots).

When only one person visits, they collect 66 liters of water. If multiple people visit, the water is divided equally: two people take 33 liters each, and three people take 22 liters each.

Your task is to calculate how much water Alice, Bob, and Carol collect over mm days, starting from day 11.

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The only line of each test case contains four integers aa, bb, cc, and mm (1a,b,c1061 \le a, b, c \le 10^6; 1m10171 \le m \le 10^{17}).

Output

For each test case, print three integers — the number of liters of water that Alice, Bob, and Carol collect over mm days.

Note

Consider the first example:

  • on day 11, only Bob visits the spring, and he collects 66 liters;
  • on day 22, Alice and Bob visit the spring, and they each collect 33 liters;
  • on day 33, Bob and Carol visit the spring, and they each collect 33 liters;
  • on day 44, Alice and Bob visit the spring, and they each collect 33 liters;
  • on day 55, only Bob visits the spring, and he collects 66 liters;
  • on day 66, Alice, Bob, and Carol visit the spring, and they each collect 22 liters;
  • on day 77, only Bob visits the spring, and he collects 66 liters;
  • on day 88, Alice and Bob visit the spring, and they each collect 33 liters;
  • on day 99, Bob and Carol visit the spring, and they each collect 33 liters;
  • on day 1010, Alice and Bob visit the spring, and they each collect 33 liters.

Samples

4
2 1 3 10
1 1 8 5
6 20 15 1000
650650 1092 157437 100000000000000000
14 38 8 
15 15 0 
881 236 281 
845294870595 549337065358857 3774389867286 

在线编程 IDE

建议全屏模式获得最佳体验