Timer is Running

Lohia , Gosu and Prince are footballers. Lohia and Gosu are strikers while Prince is a goalkeeper. You as the coach held a practice session of penalty shootouts to improve the performance of the strikers . Your task is to find the maximum goal scorer between the two.

Lohia, Gosu and Prince energy is denoted by X, Y and Z respectively. For every goal scored the energy of the respective player is decreased by 1 and after every save Prince energy is decreased by 1. Strikers will be able to score the goal if Prince energy is a factor of their energy otherwise not.

The session ends when Prince's energy reaches 1.

Assume same player can try for goals repeatedly and they both try to increase number of goals in totality. Lohia being a junior player is always favoured for penalty kick.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Each test case contains energy 3 integers **X, Y **&** Z , **denoting the energies respectively.

**Output:**

For each test case print the number of goals scored by Lohia and Gosu respectively.

**Constraints:**

1 <= T <= 100

1 <= X,Y,Z <= 10^{5}

**Example:**

**Input:**

2

4 9 5

13 10 7

**Output:**

3 2

0 3

**Explanation:**

**Case 1:**

Goal will not be scored because Z is not a factor of X and Y hence (X-4 , Y-9 , Z-4). Now goal will be scored by (X=1) X-3 , Y-9 , Z-4 ---> X-3 , Y-9 , Z-3 ---> (X=2)X-2, Y-9 , Z-3 ---> (X=2 , Y=1)X-2 , Y-8 , Z-3 ---> X-2, Y-8 , Z-2 ---> (X=3 , Y=1)X-1, Y-8 , Z-2 ---> (X=3, Y=2)X-1 , Y-7 , Z-1. Now the session will end because Prince’s energy reaches 1.

**Case 2:**

Since X is a prime number goal by X will never be scored therefore only Y will be able to score.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

abnandi04 | 801 |

KshamaGupta | 562 |

mummy | 326 |

jagseersinghbe18cse | 296 |

ponnadasaikesav | 292 |

abnandi04 | 776 |

KshamaGupta | 446 |

yogesh_aka_dante | 288 |

ponnadasaikesav | 269 |

mummy | 239 |

blackshadows | 5362 |

Ibrahim Nash | 5244 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4748 |

Login to report an issue on this page.