时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒 空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M 64bit IO Format: %lld
题目描述
You are given integers and , and there are fractions as follows: Please reduce each fraction to its simplest form and calculate the sum of the numerators. A fraction is in simplest form if and only if , where denotes the greatest common divisor (GCD) of integers and . For example, the simplest form of is , and the simplest form of is .
输入描述:
The first line contains an integer --- the number of test cases. Each test case consists of one line containing integers and .