LearnToCP
Sign in

Navigation

HomeRoadmapProblemsAbout Us

Theory

Contest Knowledge
Selecting an IDE
Basics
Your First ProgramData types and IOC++ syntaxModuloFunctionsVectorsMatricesTime Complexity
Sorting
SortingCounting sortRadix Sort
Optimization Techniques
Two PointersSum of numbers 1 to nPrefix sumBinary SearchGreedyBinary Search FunctionsBinary Search by AnswerDivide and Conquer
Binary Numbers
Binary NumbersNumbers in codeBitwise OperationsBitmasks
Math
Binary ExponentiationPrime NumbersPrime FactorizationGCD and LCMSieve of EratosthenesModified Sieve
Data Structures
StringsStackQueueMapsSetsPriority QueueCustom Criteria for FunctionsSegment TreesFenwick TreesSparse TablesUnion Find
Combinatorics
Addition PrincipleMultiplication PrincipleCombinatoric ObjectsInclusion Exclusion Principle
Geometry
Geometry BasicsVectorsCross and Dot ProductLinesPolygonsAnglesPoint in PolygonDistances and Intersection PointsConvex HullCircles
Recursion
PointersRecursionGenerating Combinatoric Objects
Dynamic Programming
About DPTree DPBitmask DPDigit DP
Graph Theory
GraphsDFS and BFSShortest PathsTreesTopological SortingDijkstra's AlgorithmMinimum Spanning TreesShortest Path Algorithms
Advanced Graph Theory
BiconnectivityStrongly Connected ComponentsBipartite GraphGraph FlowAugmenting PathsFlow - Minimum Cut DualityHeavy-Light DecompositionCentroid Decomposition
Advanced Data Structures
2D and 3D Segment TreesLazy PropagationImplicit Segment TreesPersistent Segment TreesLowest Common AncestorTrieBalanced Binary Search TreesMo's Algorithm

Insect Teams

EasyProblem #24
Time LimitMemoryInputOutputTAGS
1 s64 MBstdinstdout
#math

Ants, bees and mosquitoes are organizing a sports tournament. They want to split into teams so that every team consists of a single insect kind, all teams have the same number of members, and every insect is in exactly one team. Given the number of insects of each kind, your task is to determine the largest possible team size.

Input

First line of input will be a single integer t - the number of testcases.
Each of the next t lines contains three integers a, b and c - the number of ants, bees and mosquitoes.

Output

For every testcase print a single line with the largest possible team size.

Example

Input
2
20 30 40
1000000000 2000000000 500000000
Output
10
500000000

In the first testcase teams of 10 work: 2 teams of ants, 3 of bees and 4 of mosquitoes. No bigger size divides all three numbers.

Constraints

1≤t≤1000
1≤a,b,c≤2⋅109


This problem was adapted, with permission, from Najveći zajednički delilac, authored by Društvo matematičara Srbije and Fondacija Petlja.

Submit your solution

Sign in to submit your solution and track your progress.

Sign in