Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.

Recently, she was presented with an array $a$ of the size of $10^9$ elements that is filled as follows:   $a_1 = -1$  $a_2 = 2$  $a_3 = -3$  $a_4 = 4$  $a_5 = -5$  And so on ... 

That is, the value of the $i$-th element of the array $a$ is calculated using the formula $a_i = i \cdot (-1)^i$.

She immediately came up with $q$ queries on this array. Each query is described with two numbers: $l$ and $r$. The answer to a query is the sum of all the elements of the array at positions from $l$ to $r$ inclusive.

Margarita really wants to know the answer to each of the requests. She doesn't want to count all this manually, but unfortunately, she couldn't write the program that solves the problem either. She has turned to you — the best programmer.

Help her find the answers!


-----Input-----

The first line contains a single integer $q$ ($1 \le q \le 10^3$) — the number of the queries.

Each of the next $q$ lines contains two integers $l$ and $r$ ($1 \le l \le r \le 10^9$) — the descriptions of the queries.


-----Output-----

Print $q$ lines, each containing one number — the answer to the query. 


-----Example-----
Input
5
1 3
2 5
5 5
4 4
2 3

Output
-2
-2
-5
4
-1



-----Note-----

In the first query, you need to find the sum of the elements of the array from position $1$ to position $3$. The sum is equal to $a_1 + a_2 + a_3 = -1 + 2 -3 = -2$.

In the second query, you need to find the sum of the elements of the array from position $2$ to position $5$. The sum is equal to $a_2 + a_3 + a_4 + a_5 = 2 -3 + 4 - 5 = -2$.

In the third query, you need to find the sum of the elements of the array from position $5$ to position $5$. The sum is equal to $a_5 = -5$.

In the fourth query, you need to find the sum of the elements of the array from position $4$ to position $4$. The sum is equal to $a_4 = 4$.

In the fifth query, you need to find the sum of the elements of the array from position $2$ to position $3$. The sum is equal to $a_2 + a_3 = 2 - 3 = -1$.

Difficulty: interview

Starter code:

Solutions:
def s(k):
	if k % 2 == 0:
		return k // 2
	else:
		return - (k + 1) // 2


for i in range(int(input())):
	l, r = list(map(int, input().split()))
	print(s(r) - s(l - 1))


def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

for _ in range(ii()):
    l, r = mi()
    l -= 1
    sr = r // 2 + (r % 2) * -r
    sl = l // 2 + (l % 2) * -l
    print(sr - sl)

def main():
    def calc(x):
        if x & 1:
            return -x + calc(x - 1)
        return x // 2
    n = int(input())
    for i in range(n):
        a, b = list(map(int, input().split()))
        print(calc(b) - calc(a - 1))    

main()


n = int(input())
for i in range(n):
    a,b = list(map(int, input().split()))
    a1 = a
    if a % 2 == 0:
        a1 += 1
    b1 = b
    if b % 2 == 0:
        b1 -= 1
    n = 0
    if a1 <= b1:
        num = (b1 - a1) // 2 + 1
        n = num * (b1 + a1) // 2
        n *= -1
    b2 = b
    a2 = a
    if a % 2 == 1:
        a2 += 1
    if b % 2 == 1:
        b2 -= 1
    n2 = 0
    if a2 <= b2:
        num = (b2 - a2) // 2 + 1
        n2 = num * (b2 + a2) // 2
    print(n + n2)



import math
n  = int(input())

for i in range(n):
    l,r = [*map(int, input().split())]
    l-=1
    war1 = math.ceil(l/2)
    if(l%2 == 1):
        war1 = -1*war1
    
    war2 = math.ceil(r/2)
    if(r%2 == 1):
        war2 = -1*war2

    print(war2-war1)

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    if l % 2 == 0:
        count = -((r - l + 1) // 2)
    else:
        count = ((r - l + 1) // 2)
    if (r - l + 1) % 2 == 0:
        print(count)
    else:
        if r % 2 == 0:
            print(count + r)
        else:
            print(count - r)

n = int(input())
for _ in range(n):
    l, r = map(int, input().split())
    if (l - r) % 2 == 1:
        if l % 2:
            print((r-l+1)//2)
        else:
            print(-((r-l+1)//2))
    else:
        ans = 0
        if l % 2:
            ans = ans + (r-l)//2
        else:
            ans = ans + -(r-l)//2
        if r % 2:
            ans = ans - r
        else:
            ans = ans + r
        print(ans)

import sys
input = sys.stdin.readline

Q=int(input())
LR=[list(map(int,input().split())) for i in range(Q)]

#正:N//2個の和
#負:(N+1)//2個の和

def SUM(i):
    plus=i//2
    minus=(i+1)//2

    P=(2+2*plus)*plus//2
    M=(1+2*minus-1)*minus//2
    return P-M

for l,r in LR:
    print(SUM(r)-SUM(l-1))


''' CODED WITH LOVE BY SATYAM KUMAR '''


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left,bisect,bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10**6) # max depth of recursion
threading.stack_size(2**27)  # new thread will get stack of such size

printHeap = str()
memory_constrained = False
P = 10**9+7
import sys
sys.setrecursionlimit(10000000)

class Operation:
    def __init__(self, name, function, function_on_equal, neutral_value=0):
        self.name = name
        self.f = function
        self.f_on_equal = function_on_equal
def add_multiple(x, count):
    return x * count
def min_multiple(x, count):
    return x
def max_multiple(x, count):
    return x
sum_operation = Operation("sum", sum, add_multiple, 0)
min_operation = Operation("min", min, min_multiple, 1e9)
max_operation = Operation("max", max, max_multiple, -1e9)
class SegmentTree:
    def __init__(self,
                 array,
                 operations=[sum_operation, min_operation, max_operation]):
        self.array = array
        if type(operations) != list:
            raise TypeError("operations must be a list")
        self.operations = {}
        for op in operations:
            self.operations[op.name] = op
        self.root = SegmentTreeNode(0, len(array) - 1, self)
    def query(self, start, end, operation_name):
        if self.operations.get(operation_name) == None:
            raise Exception("This operation is not available")
        return self.root._query(start, end, self.operations[operation_name])
    def summary(self):
        return self.root.values
    def update(self, position, value):
        self.root._update(position, value)
    def update_range(self, start, end, value):
        self.root._update_range(start, end, value)
    def __repr__(self):
        return self.root.__repr__()
class SegmentTreeNode:
    def __init__(self, start, end, segment_tree):
        self.range = (start, end)
        self.parent_tree = segment_tree
        self.range_value = None
        self.values = {}
        self.left = None
        self.right = None
        if start == end:
            self._sync()
            return
        self.left = SegmentTreeNode(start, start + (end - start) // 2,
                                    segment_tree)
        self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end,
                                     segment_tree)
        self._sync()
    def _query(self, start, end, operation):
        if end < self.range[0] or start > self.range[1]:
            return None
        if start <= self.range[0] and self.range[1] <= end:
            return self.values[operation.name]
        self._push()
        left_res = self.left._query(start, end,
                                    operation) if self.left else None
        right_res = self.right._query(start, end,
                                      operation) if self.right else None
        if left_res is None:
            return right_res
        if right_res is None:
            return left_res
        return operation.f([left_res, right_res])
    def _update(self, position, value):
        if position < self.range[0] or position > self.range[1]:
            return
        if position == self.range[0] and self.range[1] == position:
            self.parent_tree.array[position] = value
            self._sync()
            return
        self._push()
        self.left._update(position, value)
        self.right._update(position, value)
        self._sync()
    def _update_range(self, start, end, value):
        if end < self.range[0] or start > self.range[1]:
            return
        if start <= self.range[0] and self.range[1] <= end:
            self.range_value = value
            self._sync()
            return
        self._push()
        self.left._update_range(start, end, value)
        self.right._update_range(start, end, value)
        self._sync()
    def _sync(self):
        if self.range[0] == self.range[1]:
            for op in self.parent_tree.operations.values():
                current_value = self.parent_tree.array[self.range[0]]
                if self.range_value is not None:
                    current_value = self.range_value
                self.values[op.name] = op.f([current_value])
        else:
            for op in self.parent_tree.operations.values():
                result = op.f(
                    [self.left.values[op.name], self.right.values[op.name]])
                if self.range_value is not None:
                    bound_length = self.range[1] - self.range[0] + 1
                    result = op.f_on_equal(self.range_value, bound_length)
                self.values[op.name] = result
    def _push(self):
        if self.range_value is None:
            return
        if self.left:
            self.left.range_value = self.range_value
            self.right.range_value = self.range_value
            self.left._sync()
            self.right._sync()
            self.range_value = None
    def __repr__(self):
        ans = "({}, {}): {}\n".format(self.range[0], self.range[1],
                                      self.values)
        if self.left:
            ans += self.left.__repr__()
        if self.right:
            ans += self.right.__repr__()
        return ans

def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")

def primeFactors(n): #n**0.5 complex 
    factors = dict()
    for i in range(2,math.ceil(math.sqrt(n))+1):  
        while n % i== 0: 
            if i in factors:
                factors[i]+=1
            else: factors[i]=1
            n = n // i 
    if n>2:
        factors[n]=1
    return (factors)
    
def isprime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True

def test_print(*args):
    if testingMode:
        print(args)

def display_list(list1, sep=" "):
    stdout.write(sep.join(map(str, list1)) + "\n")

def get_int():
    return int(stdin.readline().strip())

def get_tuple():
    return map(int, stdin.readline().split())

def get_list():
    return list(map(int, stdin.readline().split()))

memory = dict()
def clear_cache():
    nonlocal memory
    memory = dict()
def cached_fn(fn, *args):
    nonlocal memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result


# -------------------------------------------------------------- MAIN PROGRAM
TestCases = True
testingMode = False
optimiseForReccursion = False #Can not be used clubbed with TestCases
            

def main():
    l,r= get_tuple()
    size = r-l+1
    res=0
    if l%2!=0:
        res+=size//2
        if size%2!=0:
            res+=(-1)**r * r
    else:
        res-=size//2
        if size%2!=0:
            res+=(-1)**r * r
    print(res)

    
        
            


# --------------------------------------------------------------------- END


if TestCases: 
    for _ in range(get_int()): 
        cProfile.run('main()') if testingMode else main() 
else: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()

# -*- coding: utf-8 -*-

import math
import collections
import bisect
import heapq
import time
import itertools
import sys

"""
created by shhuan at 2018/11/24 15:28

"""

Q = int(input())
ans = []

for i in range(Q):
    l, r = map(int, input().split())
    if l % 2 == 0 and r % 2 == 0:
        ans.append((r-l)//2 + l)
    elif l % 2 == 1 and r % 2 == 0:
        ans.append((r-l+1)//2)
    elif l % 2 == 1 and r % 2 == 1:
        ans.append(0-(r-l)//2-l)
    else:
        ans.append(0-(r-l+1)//2)

print('\n'.join(map(str, ans)))

cs = int(input())

for c in range(cs):
    l, r = map(int, input().split())
    #odd     => -
    #even    => +
    
    if l%2 == 0 and r%2 == 0:
        print((r - l) // 2 + l)
    if l%2 == 1 and r%2 == 0:
        print((r - l + 1) // 2)
    if l%2 == 0 and r%2 == 1:
        print(-(r - l + 1) // 2)
    if l%2 == 1 and r%2 == 1:
        print(-(r - l) // 2 - l)

#      
import collections, atexit, math, sys, bisect 

sys.setrecursionlimit(1000000)
def getIntList():
    return list(map(int, input().split()))    

try :
    #raise ModuleNotFoundError
    import numpy
    def dprint(*args, **kwargs):
        #print(*args, **kwargs, file=sys.stderr)
        # in python 3.4 **kwargs is invalid???
        print(*args,  file=sys.stderr)
    dprint('debug mode')
except Exception:
    def dprint(*args, **kwargs):
        pass



inId = 0
outId = 0
if inId>0:
    dprint('use input', inId)
    sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件
if outId>0:
    dprint('use output', outId)
    sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件
    atexit.register(lambda :sys.stdout.close())     #idle 中不会执行 atexit
    
N, = getIntList()
#print(N)

for _ in range(N):
    l,r = getIntList()
    n = (r-l+1)
    z = n//2
    if l%2==0:
        z*=-1
    if n%2==1:
        if r%2==0:
            z += r
        else:
            z-=r
    print(z)

    






Q = int(input())

def getsum(N):
    A = (N+1)//2
    r1 = -A + A*(A+1)
    B = N // 2
    r2 = B*(B+1)
    return -r1 + r2

while Q != 0:
    L, R = list(map(int, input().split()))
    print(getsum(R) - getsum(L-1))
    Q -= 1
    


def getsum(a, b):
    if a % 2 == 0:
        return (a + b) * ((b - a) // 2 + 1) // 2
    else:
        return -(a + b) * ((b - a) // 2 + 1) // 2

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    if l == r:
        print(l if l % 2 == 0 else -l)
    else:
        print(
            getsum(l if l % 2 == 1 else l + 1, r if r % 2 == 1 else r - 1) + 
            getsum(l if l % 2 == 0 else l + 1, r if r % 2 == 0 else r - 1)
        )

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    aa = [LI() for _ in range(n)]
    r = []
    for a,b in aa:
        al = a + (1-a%2)
        ar = b - (1-b%2)
        sa = (ar-al) // 2 + 1
        tr = -(al+ar) * sa // 2

        bl = a + (a%2)
        br = b - (b%2)
        sb = (br-bl) // 2 + 1
        tr += (bl+br) * sb // 2
        r.append(tr)

    return "\n".join(map(str,r))


print(main())


# from math import ceil
# n, k = map(int, input().split())
# print(ceil(n*2/k) + ceil(n*5/k) + ceil(n*8/k))

for _ in range(int(input())):
    i, j = map(int, input().split())
    i -= 1
    print(j//2 * (j//2 + 1) - i//2 * (i//2 + 1) - 
          (((j - j//2) * (j - j//2)) - ((i - i//2) * (i - i//2)))) 

q = int(input())
for _ in range(q):
	l, r = list(map(int, input().split()))
	sign = -1 if l % 2 else 1
	if (r-l) % 2:
		print(-sign*(r-l+1)//2)
	else:
		print(sign*(l+(r-l)//2))



from collections import defaultdict
# from fractions import Fraction
def read_line():
    return [int(x) for x in input().split()]


def query(l, r):
    if l == r:
        if l % 2 == 0: return l
        else: return -r
    if l % 2 == 1:
        return -l + query(l+1, r)
    if r % 2 == 0:
        return r + query(l, r-1)

    num_pairs = (r+1 - l ) // 2
    sm_even = l * num_pairs + num_pairs * (num_pairs-1)
    sm_odd = -(sm_even + num_pairs)
    return sm_even + sm_odd

# test = [i * (-1)**i for i in range(100)]
# for i in range(1, 100):
#     for j in range(i, 100):
#         print(i, j, query(i, j), sum(test[x] for x in range(i, j+1)))
#         assert query(i, j) == sum(test[x] for x in range(i, j+1))

q = int(input())
for _ in range(q):
    l, r = read_line()
    print(query(l, r))



def solve(n):
	even = (n//2) * (n//2 + 1)
	odd = ((n+1)//2) * ((n+1)//2)
	return even - odd

Q = int(input())
for _ in range(Q):
	(l, r) = list(map(int, input().split(' ')))
	ans = solve(r) - solve(l-1)
	print(ans)

for i in range(int(input())):
    l,r=list(map(int,input().split()))
    if l==r:
        print(((-1)**(l%2))*l)
    elif l%2==1 and r%2==0:
        print((r-l+1)//2)
    elif l%2==1 and r%2==1:
        print(((r-l)//2)-r)
    elif l%2==0 and r%2==0:
        print(((r-l)//2)+l)
    elif l%2==0 and r%2==1:
        print(((r-l-1)//2)+l-r)


from math import ceil 

t = int(input())
for test in range(t):
    l, r = (list(map(int, input().split())))
    odd = 0
    st = 2*ceil(l/2)
    end = 2*(r//2)
    even = ((st + end)*(((end-st)//2)+1) )//2
    st = 2*(l//2)+1
    end = 2*ceil(r/2)-1
    odd = ((st + end)*(((end-st)//2)+1) )//2
    print(int(even-odd))