Problem: You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.

For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .... The 7-th number among them is 10.

Input

The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases in the input. Next, t test cases are given, one per line.

Each test case is two positive integers n (2 ≤ n ≤ 10^9) and k (1 ≤ k ≤ 10^9).

Output

For each test case print the k-th positive integer that is not divisible by n.

Example

Input


6
3 7
4 12
2 1000000000
7 97
1000000000 1000000000
2 1


Output


10
15
1999999999
113
1000000001
1

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
import java.lang.*;
import java.util.Comparator;

public class ai {
    InputStream is;
    PrintWriter out;
    long mod = (long)(1e9 + 7), inf = (long)(3e18);
    int cnt[];
    void solve() throws IOException {
        int t = ni();
        while(t>0){
            t--;
            long n = ni();
            long k = ni();
            long start = 1;
            long end = 1000000000000000000l;
            long mid=0;
            while(start < end){
                mid = (start+end)/2;
                long ans = mid - (mid/n);
                if(ans == k){
                    break;
                }
                if(ans > k){
                    end = mid;
                }
                else{
                    start = mid+1;
                }
            }
            if(mid%n==0)mid--;
            System.out.println(mid);
        }
    }
    public void build(long arr[],long brr[],int a[],int n,int l,int r){
        if(l==r){
            arr[n] = brr[n] = a[l];
        }
        else{
            int mid = (l+r)/2;
            build(arr,brr,a,2*n,l,mid);
            build(arr,brr,a,2*n+1,mid+1,r);
            arr[n] = arr[2*n] + arr[2*n+1];
            brr[n] = Math.max(brr[2*n],brr[2*n+1]);
        }
    }
    public long sum(long arr[],int l,int r,int n,int start,int end){
        if(start>end)return 0;
        if(l==start && r==end){
            return arr[n];
        }
        int mid = (l+r)/2;
        return sum(arr,l,mid,2*n,start,Math.min(end,mid)) + sum(arr,mid+1,r,2*n+1,Math.max(mid+1,start),end);
    }
    public void increment(long arr[],long brr[],int n,int l,int r,int tl,int tr,HashMap<Long,Integer> map){
        if(l>r)return;
        if(l==r && tl==tr){
            arr[n] = map.get(arr[n]);
            brr[n] = map.get(brr[n]);
        }
        else{
            int mid = (tl+tr)/2;
            if(brr[2*n]>2)
            increment(arr,brr,2*n,l,Math.min(r,mid),tl,mid,map);
            if(brr[2*n+1]>2)
            increment(arr,brr,2*n+1,Math.max(l,mid+1),r,mid+1,tr,map);
            arr[n] = arr[2*n] + arr[2*n+1];
            brr[n] = Math.max(brr[2*n],brr[2*n+1]);
        }
    }
    public int[] sieve(int n){
        int []ans = new int[n];
        ans[1]=1;
        int i=2;
        while(i<n){
            if(ans[i]==0){
                int j=2*i;
                ans[i]=i;
                while(j<n){
                    if(ans[j]==0)
                        ans[j] = i;
                    j+=i;
                }
            }
            i++;
        }
        return ans;
    }
    public static void main(String[] args)throws Exception { new ai().run(); }
    void run() throws Exception {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
}