• + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    if name == 'main': t = int(input().strip())

    for i in range(t):
        first_multiple_input = input().rstrip().split()
        n = int(first_multiple_input[0])
        k = int(first_multiple_input[1])
        L = []
        L1 = []
        for i in range(n):
            L.append(i)
        l = 0
        r = n-1
        while l<r:
            L1.append(L[r])
            L1.append(L[l])
            l += 1
            r -= 1
        if l == r:
            L1.append(L[l])
        print(L1.index(k))