Sir please help me with approach in this question I was stuck for a fair amount of time on this one

following operations on a triple of integers. In one operation, you should:

Choose an integer d and an arithmetic operation ― either addition or multiplication.
Choose a subset of elements of the triple.
Apply the arithmetic operation to each of the chosen elements, i.e. either add d to each of them or multiply each of them by d.
For example, if we have a triple (3,5,7), we may choose to add 3 to the first and third element, and we get (6,5,10) using one operation.

You are given an initial triple (p,q,r) and a target triple (a,b,c). Find the minimum number of operations needed to transform (p,q,r) into (a,b,c).

Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains three space-separated integers p, q and r.
The second line contains three space-separated integers a, b and c.
Output
For each test case, print a single line containing one integer ― the minimum required number of operations.

Constraints
1≤T≤1,000
|p|,|q|,|r|,|a|,|b|,|c|≤109
Subtasks
Subtask #1 (10 points): |p|,|q|,|r|,|a|,|b|,|c|≤10
Subtask #2 (90 points): original constraints

Example Input
2
3 5 7
6 5 10
8 6 3
9 7 8
Example Output
1
2
Explanation
Example case 1: We add 3 to the first and third element of (3,5,7) to form (6,5,10).

Example case 2: We can add 1 to each element to form (9,7,4) and then multiply the third element by 2.

@affanahmed,

Can’t help you with the ongoing contest problems. Exact problem statement of: https://www.codechef.com/JUNE20B/problems/TTUPLE/

Ok it’s 5 days to contest after that please help with the problem as I am totally clueless about theses type problems.

@affanahmed,
Only once the contest is over, I can help you. Sure.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.