importjava.io.*;publicclassMain{staticBufferedReader bf =newBufferedReader(newInputStreamReader(System.in));staticBufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));publicstaticvoidsolve()throwsIOException{String[] str = bf.readLine().split(" ");int a =Integer.parseInt(str[0]);int b =Integer.parseInt(str[1]);int c =Integer.parseInt(str[2]);int d =Math.abs(a - b);int ans =(d +2* c -1)/(2* c);
bw.write(ans +"\n");}publicstaticvoidmain(String[] args)throwsIOException{intT=Integer.parseInt(bf.readLine());while(T-->0){solve();}
bw.close();}}
importjava.io.*;publicclassMain{staticBufferedReader bf =newBufferedReader(newInputStreamReader(System.in));staticBufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));publicstaticvoidsolve()throwsIOException{int n =Integer.parseInt(bf.readLine());int ans =1000000000;for(int i =0; i < n; i++){String[] str = bf.readLine().split(" ");int d =Integer.parseInt(str[0]);int s =Integer.parseInt(str[1]);
ans =Math.min(ans, d +(s -1)/2);}
bw.write(ans +"\n");}publicstaticvoidmain(String[] args)throwsIOException{intT=Integer.parseInt(bf.readLine());while(T-->0){solve();}
bw.close();}}
importjava.io.*;publicclassMain{staticBufferedReader bf =newBufferedReader(newInputStreamReader(System.in));staticBufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));publicstaticlonggcd(long a,long b){return b ==0? a :gcd(b, a % b);}publicstaticlonglcm(long a,long b){return a * b /gcd(a, b);}publicstaticvoidsolve()throwsIOException{String[] str = bf.readLine().split(" ");long n =Long.parseLong(str[0]);long x =Long.parseLong(str[1]);long y =Long.parseLong(str[2]);long l =lcm(x, y);long pos = n / x - n / l;long neg = n / y - n / l;long ans =(n + n - pos +1)* pos /2-(neg +1)* neg /2;
bw.write(ans +"\n");}publicstaticvoidmain(String[] args)throwsIOException{intT=Integer.parseInt(bf.readLine());while(T-->0){solve();}
bw.close();}}
importjava.io.*;importjava.util.ArrayList;importjava.util.LinkedList;importjava.util.Queue;publicclassMain{staticBufferedReader bf =newBufferedReader(newInputStreamReader(System.in));staticBufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));publicstaticvoidsolve()throwsIOException{int n =Integer.parseInt(bf.readLine());String[] str = bf.readLine().split(" ");int[] a =newint[n +1];int[] in =newint[n +1];for(int i =1; i <= n; i++){
a[i]=Integer.parseInt(str[i -1]);
in[a[i]]++;}
str = bf.readLine().split(" ");int[] c =newint[n +1];for(int i =1; i <= n; i++){
c[i]=Integer.parseInt(str[i -1]);}Queue<Integer>Q=newLinkedList<>();for(int i =1; i <= n; i++){if(in[i]==0){Q.add(i);}}ArrayList<Integer> arrayList =newArrayList<>();while(!Q.isEmpty()){int x =Q.remove();
arrayList.add(x);if(--in[a[x]]==0)Q.add(a[x]);}for(int i =1; i <= n; i++){if(in[i]!=0){int x = i, mid = c[i], s = i;do{
x = a[x];
in[x]=0;if(mid > c[x]){
mid = c[x];
s = x;}}while(x != i);
x = s;do{
x = a[x];
arrayList.add(x);}while(x != s);}}for(Integer ai : arrayList)
bw.write(ai +" ");
bw.write("\n");}publicstaticvoidmain(String[] args)throwsIOException{intT=Integer.parseInt(bf.readLine());while(T-->0){solve();}
bw.close();}}
importjava.io.*;importjava.util.ArrayList;publicclassMain{staticBufferedReader bf =newBufferedReader(newInputStreamReader(System.in));staticBufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));publicstaticvoidsolve()throwsIOException{int n =Integer.parseInt(bf.readLine());String[] str = bf.readLine().split(" ");int[] a =newint[n +1];for(int i =0; i < n; i++){
a[i]=Integer.parseInt(str[i]);}int l =0, r = n -1;while(l < r && a[l]==1) l++;while(l < r && a[r]==1) r--;long res =1;boolean ok =false;for(int i = l; i <= r; i++){
res *= a[i];if(res >1000000000L){
ok =true;
bw.write((l +1)+" "+(r +1)+"\n");break;}}if(ok)return;ArrayList<Integer> p =newArrayList<>();for(int i =0; i < n; i++){if(a[i]>1){
p.add(i);}}int sum =0;for(int i =0; i < n; i++) sum += a[i];intL=1,R=1;int ans = sum;for(int i =0; i < p.size(); i++){int ll = p.get(i);int ress =1;int s =0;for(int j = i; j < p.size(); j++){int rr = p.get(j);
ress *= a[rr];
s += a[rr]-1;int v = sum -(rr - ll +1)- s + ress;if(v > ans){
ans = v;L= ll +1;R= rr +1;}}}
bw.write(L+" "+R+"\n");}publicstaticvoidmain(String[] args)throwsIOException{intT=Integer.parseInt(bf.readLine());while(T-->0){solve();}
bw.close();}}