Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is n. 

There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains 2 apartments, every other floor contains x apartments each. Apartments are numbered starting from one, from the first floor. I.e. apartments on the first floor have numbers 1 and 2, apartments on the second floor have numbers from 3 to (x + 2), apartments on the third floor have numbers from (x + 3) to (2 ⋅ x + 2), and so on.

Your task is to find the number of floor on which Petya lives. Assume that the house is always high enough to fit at least n apartments.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.

The only line of the test case contains two integers n and x (1 ≤ n, x ≤ 1000) — the number of Petya's apartment and the number of apartments on each floor of the house except the first one (there are two apartments on the first floor).

Output

For each test case, print the answer: the number of floor on which Petya lives.

Example

Input


4
7 3
1 5
22 5
987 13


Output


3
1
5
77

Note

Consider the first test case of the example: the first floor contains apartments with numbers 1 and 2, the second one contains apartments with numbers 3, 4 and 5, the third one contains apartments with numbers 6, 7 and 8. Therefore, Petya lives on the third floor.

In the second test case of the example, Petya lives in the apartment 1 which is on the first floor.


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;


public class A {
    final static long MOD = 1000000007;

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int t = fs.nextInt();

        while(t > 0) {
            t-=1;
            int t_n = fs.nextInt();
            int d = fs.nextInt();

            double nthTerm = Math.ceil((t_n - 2.0) / d) + 1;
            out.println((int)nthTerm == 0 ? 1 : (int)nthTerm);
        }
        out.flush();
        out.close();
    }

    static class ITEM {
        long value;
        public ITEM(long sum) {
            this.value = sum;
        }
    }

    static class SegmentTree {
        int size;
        ITEM [] calc;

        private ITEM NUETRAL_ELEMENT() {
            return new ITEM(-1);
        }

        private ITEM MERGE(ITEM left, ITEM right) {
            return new ITEM(Math.max(left.value , right.value));
        }

        private ITEM SINGLE_ELEMENT(int v) {
            return new ITEM(v);
        }

        SegmentTree(int n) {
            size = 1;
            while(size < n) size*=2;
            calc = new ITEM[2 * size];
        }

        public void build(int a[]) {
            build(a, 0, 0, size);
        }

        public void set(int i, int v) {
            set(i, v, 0, 0, size);
        }

        /*public ITEM calc(int l, int r) {
            return calc(l, r, 0, 0, size);
        }*/

        public ITEM find(int k, int l) {
            return find(k, 0, l, 0, size);
        }

        private ITEM find(int k, int x,int l, int lx, int rx) {
            if(calc[x].value < k) return new ITEM(-1);
            if(rx <= l) return new ITEM(-1);
            if(rx - lx == 1) return new ITEM(lx);
            int m = (lx + rx) / 2;
            ITEM res = find(k, 2 * x + 1, l, lx, m);
            if(res.value == -1) {
                return find(k, 2 * x + 2, l, m, rx);
            }
            return res;
        }

        private void build(int[] a, int x, int lx, int rx) {
            if(rx - lx == 1) {
                calc[x] = lx < a.length ? SINGLE_ELEMENT(a[lx]) : NUETRAL_ELEMENT();
                return;
            }
            int m = (lx + rx) / 2;
            build(a, 2 * x + 1, lx, m);
            build(a, 2 * x + 2, m, rx);
            calc[x] = MERGE(calc[2 * x + 1], calc[2 * x + 2]);
        }

        private void set(int i, int v, int x, int lx, int rx) {
            if(rx - lx == 1) {
                calc[x] = SINGLE_ELEMENT(v);
                return;
            }
            int m = (lx + rx) / 2;
            if(i < m) {
                set(i, v, 2 * x + 1, lx, m);
            } else {
                set(i, v, 2 * x + 2, m, rx);
            }
            calc[x] = MERGE(calc[2 * x + 1], calc[2 * x + 2]);
        }

       /* private ITEM calc(int l, int r, int x, int lx, int rx) {
            if(lx >= r || l >= rx) return NUETRAL_ELEMENT();
            if(lx >= l && rx <= r) return calc[x];

            int m = (lx + rx) / 2;

            ITEM left = calc(l, r, 2 * x + 1, lx, m);
            ITEM right = calc(l, r, 2 * x + 2, m, rx);

            return MERGE(left, right);
        }*/

    }

    static void shuffleArray(long[] ar)
    {
        Random rnd = ThreadLocalRandom.current();
        for (int i = ar.length - 1; i > 0; i--)
        {
            int index = rnd.nextInt(i + 1);
            long a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;
        }
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                // br = new BufferedReader(new FileReader("chat.txt"));
                st = new StringTokenizer("");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String next() {
            if (st.hasMoreTokens())
                return st.nextToken();
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String line = "";
            try {
                line = br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return line;
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }

}




