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$.

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
for _ in range(int(input())):
	(l, r) = [int(i) for i in input().split()]
	s = 0
	if l == r:
		if l % 2:
			print(-l)
		else:
			print(l)
	else:
		if l % 2 == 0:
			s += l
			l += 1
		if r % 2:
			s -= r
			r -= 1
		if l == r:
			if l % 2:
				s -= l
			else:
				s += l
		else:
			n = r - l + 1
			n //= 2
			s += n * (l + 1 + r) // 2
			s -= n * (l + r - 1) // 2
		print(s)


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


a = int(input())
for i in range(a):
	(x, y) = list(map(int, input().split()))
	if x % 2 == 0:
		if y - x == 0:
			print(x)
		else:
			ans = y - x + 1
			if ans % 2 == 0:
				print(int(-1 * ans / 2))
			else:
				print(int(y + -1 * (ans - 1) / 2))
	elif y - x == 0:
		print(-x)
	else:
		ans = y - x + 1
		if ans % 2 == 0:
			print(int(ans / 2))
		else:
			print(int(-y + (ans - 1) / 2))


q = int(input())
while q:
	(l, r) = list(map(int, input().split()))
	if l == r:
		if l % 2 == 0:
			print(l)
		else:
			print(l * -1)
	else:
		oc = 0
		ec = 0
		n = r - l
		if n % 2 == 0 and l % 2 != 0:
			oc = n // 2 + 1
			ec = oc - 1
		elif n % 2 == 0 and l % 2 == 0:
			oc = n // 2
			ec = oc + 1
		else:
			oc = n // 2 + 1
			ec = oc
		starte = l if l % 2 == 0 else l + 1
		starto = l if l % 2 != 0 else l + 1
		sume = ec * (2 * starte + (ec - 1) * 2) // 2
		sumo = oc * (2 * starto + (oc - 1) * 2) // 2
		print(sume + sumo * -1)
	q = q - 1


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())
while q > 0:
	(l, r) = map(int, input().split())
	n = r - l + 1
	if n % 2 == 0:
		total = pow(-1, l + 1) * (n // 2)
	else:
		total = pow(-1, l + 1) * ((n - 1) // 2) + r * pow(-1, r)
	print(total)
	q -= 1


import math as m

def odds(n):
	oddsum = m.ceil(n / 2) ** 2
	evensum = m.floor(n / 2) * (m.floor(n / 2) + 1)
	return evensum - oddsum
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(odds(r) - odds(l - 1))


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict

def I():
	return int(sys.stdin.readline())

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

def Neo():
	return list(map(int, sys.stdin.readline().split()))
q = I()
for i in range(q):
	(l, r) = neo()
	if l % 2:
		if (r - l) % 2:
			print((r - l + 1) // 2)
		else:
			print((r - l + 1) // 2 - r)
	elif (r - l) % 2:
		print(-(r - l + 1) // 2)
	else:
		print(-((r - l + 1) // 2 - r))


q = int(input())
answer = []
while q > 0:
	[l, r] = list(map(int, input().split()))
	answer.append((r // 2 + r % 2) * (-2 * (r % 2) + 1) - (l // 2 + l % 2) * (-2 * (l % 2) + 1) + l * (-2 * (l % 2) + 1))
	q -= 1
for ans in answer:
	print(ans)


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


def calculate(index):
	if index % 2 == 0:
		sum = index / 2
	else:
		sum = (index - 1) / 2 - index
	return sum
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	sum = calculate(r) - calculate(l - 1)
	print(int(sum))


q = int(input())
while q:
	(l, r) = map(int, input().split())
	l = l - 1
	(n1, n2) = (l // 2, r // 2)
	if l % 2 == 0:
		se1 = n1 * (2 + l) // 2
		so1 = n1 * (-1 - l + 1) // 2
	else:
		se1 = n1 * (2 + l - 1) // 2
		so1 = (n1 + 1) * (-1 - l) // 2
	if r % 2 == 0:
		se2 = n2 * (2 + r) // 2
		so2 = n2 * (-1 - r + 1) // 2
	else:
		se2 = n2 * (2 + r - 1) // 2
		so2 = (n2 + 1) * (-1 - r) // 2
	print(se2 + so2 - se1 - so1)
	q -= 1


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

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))


def f(x):
	if x % 2 == 0:
		return x / 2
	else:
		return f(x - 1) - x
q = int(input())
while q > 0:
	(l, r) = map(int, input().split())
	print(int(f(r) - f(l - 1)))
	q -= 1


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


t = int(input())
for a1 in range(t):
	(m, n) = map(int, input().split())
	if m == n:
		print(m * (-1) ** m)
	else:
		a = 1 / 4 * (2 * m * (-1) ** m + (-1) ** (m + 1) + (-1) ** n + 2 * (-1) ** n * n)
		print(int(a))


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))


R = lambda : map(int, input().split())

def ans(n):
	return 0 if n == 0 else [n // 2, (n - 1) // 2 - n][n % 2 != 0]
(i, n) = (0, int(input()))
while i < n:
	(a, b) = R()
	print(ans(b) - ans(a - 1))
	i += 1


t = int(input())
c = 0
for i in range(t):
	(x, y) = map(int, input().split())
	if y % 2 == 0 and x % 2 == 0:
		print(-1 * (y - x) // 2 + y)
	elif y % 2 != 0 and x % 2 == 0:
		print(-1 * ((y - x) // 2) - 1)
	elif y % 2 == 0 and x % 2 != 0:
		print((y - x) // 2 + 1)
	elif y % 2 != 0 and x % 2 != 0:
		print((y - x) // 2 - y)


numb = int(input())
for i in range(numb):
	line = input()
	arrr = line.split(' ')
	l = int(arrr[0])
	r = int(arrr[1])
	ara = r - l + 1
	ans = 0
	if ara % 2 == 1:
		ara2 = ara // 2 + l
		a = ara % 4
		if a == 1:
			if ara2 % 2 == 0:
				ans = ara2
			else:
				ans = -ara2
		elif a == 3:
			if ara2 % 2 == 0:
				ans = -ara2
			else:
				ans = ara2
	else:
		ara2 = ara // 2 + l
		ax = ara2 - 1
		a = (ara - 1) % 4
		if a == 1:
			if ara2 % 2 == 0:
				ans = ara2 - l
			else:
				ans = -ara2 + l
		elif a == 3:
			if ara2 % 2 == 0:
				ans = -ara2 + l
			else:
				ans = ara2 - l
	print(ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		if a % 2 == 0:
			print(a)
		else:
			print(-1 * a)
	elif a % 2 != 0:
		if b % 2 != 0:
			print(-1 * (b - int((b + 1 - a) / 2)))
		else:
			print(int((b + 1 - a) / 2))
	elif b % 2 != 0:
		print(-1 * int((b + 1 - a) / 2))
	else:
		print(b - int((b + 1 - a) / 2))


nb_query = int(input())
for _ in range(nb_query):
	(l, r) = [int(x) for x in input().split()]
	y = r - l + 1
	x = y // 2
	if y & 1:
		x -= r
	if l % 2 == 0:
		x = -x
	print(x)


q = int(input())
for i in range(q):
	(l, r) = [int(x) for x in input().split()]
	n = r - l + 1
	if n % 2 == 0 and l % 2 != 0:
		print(n // 2)
	elif n % 2 == 0 and l % 2 == 0:
		print(-(n // 2))
	elif n % 2 != 0 and l % 2 != 0:
		print(-(n // 2 + l))
	elif n % 2 != 0 and l % 2 == 0:
		print(r - n // 2)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	diff = b - a + 1
	ap = a * pow(-1, a)
	bp = b * pow(-1, b)
	if a == b:
		ans = ap
	elif diff % 2 != 0 and diff > 1:
		if a % 2 == 0:
			z = diff // 2
			z = z * -1
			ans = z + bp
		else:
			z = diff // 2
			z = z * 1
			ans = z + bp
	elif a % 2 == 0 and diff > 1:
		z = diff // 2
		z = z * -1
		ans = z
	else:
		z = diff // 2
		z = z * 1
		ans = z
	print(ans)


q = int(input())

def sum(a, n):
	return n * (2 * a + (n - 1) * 2) // 2
while q is not 0:
	q -= 1
	(l, r) = list(map(int, input().split()))
	evena = 0
	odda = 0
	evenn = 0
	oddn = 0
	if l is r:
		print((-1) ** l * l)
		continue
	if r - l is 1:
		print((-1) ** l * l + (-1) ** r * r)
		continue
	if r - l is 2:
		print((-1) ** l * l + (-1) ** (l + 1) * (l + 1) + (-1) ** r * r)
		continue
	if l % 2 is 0:
		evena = l
		odda = l + 1
	else:
		evena = l + 1
		odda = l
	if r % 2 is 0:
		evenn = (r - evena) // 2 + 1
		oddn = (r - 1 - odda) // 2 + 1
	else:
		evenn = (r - 1 - evena) // 2 + 1
		oddn = (r - odda) // 2 + 1
	print(sum(evena, evenn) - sum(odda, oddn))


t = int(input())
for _ in range(0, t):
	(l, r) = map(int, input().split())
	if l == r:
		if l % 2 == 0:
			print(l)
		else:
			print(-l)
	elif l % 2 == 0:
		no_even = (r - l) // 2 + 1
		no_odd = r - l + 1 - no_even
		if r % 2 == 0:
			sum_even = no_even * (l + r)
			sum_even //= 2
			sum_odd = no_odd * (l + r)
			sum_odd //= 2
			print(sum_even - sum_odd)
		else:
			sum_even = no_even * (l + r - 1)
			sum_even //= 2
			sum_odd = no_odd * (l + 1 + r)
			sum_odd //= 2
			print(sum_even - sum_odd)
	else:
		no_odd = (r - l) // 2 + 1
		no_even = r - l + 1 - no_odd
		if r % 2 == 0:
			sum_even = no_even * (l + 1 + r)
			sum_even //= 2
			sum_odd = no_odd * (l + r - 1)
			sum_odd //= 2
			print(sum_even - sum_odd)
		else:
			sum_even = no_even * (l + r)
			sum_even //= 2
			sum_odd = no_odd * (l + r)
			sum_odd //= 2
			print(sum_even - sum_odd)


def chet(r, l):
	if (r - l + 1) % 2 == 0:
		return False
	else:
		return True
q = int(input())
a = []
for i in range(q):
	(l, r) = map(int, input().split())
	a.append((-1) ** (l + 1) * ((r - l + 1) // 2) + r * chet(r, l) * (-1) ** r)
print(*a, sep='\n')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(x, y) = (0, (b - a) // 2)
	if a % 2 == b % 2:
		x = a if a % 2 == 0 else -b
	else:
		y += 1
		if a % 2 == 0:
			y = -y
	print(x + y)


def F(x):
	if x & 1:
		return x // 2
	else:
		return F(x - 1) - x
for _ in range(int(input())):
	L = list(map(int, input().split()))
	(l, r) = (L[0], L[1])
	print(F(l - 1) - F(r))


from sys import stdin, stdout
import math
import heapq
from itertools import accumulate
Q = int(input())
for i in range(Q):
	(L, R) = [int(x) for x in stdin.readline().split()]
	odds = [0, 0]
	even = [0, 0]
	if L == R:
		if L % 2 == 1:
			print(-L)
		else:
			print(R)
		continue
	if L % 2 == 0:
		odds[0] = L + 1
		even[0] = L
	else:
		odds[0] = L
		even[0] = L + 1
	if R % 2 == 0:
		odds[1] = R - 1
		even[1] = R
	else:
		odds[1] = R
		even[1] = R - 1
	d = (odds[1] - odds[0] + 2) // 2
	od = sum(odds) * d // 2
	d = (even[1] - even[0] + 2) // 2
	ev = sum(even) * d // 2
	print(-od + ev)


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


import math

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


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))


import math

def soln(l, r):
	res = 0
	if l % 2:
		if r % 2:
			res = -l - (r - l) // 2
		else:
			res = (r - l + 1) // 2
	elif r % 2:
		res = (l - r - 1) // 2
	else:
		res = (r + l) // 2
	return res

def main():
	q = int(input())
	for _ in range(q):
		(l, r) = map(int, input().split())
		res = soln(l, r)
		print(res)
main()


def ans(x):
	if x % 2 == 0:
		return x // 2
	else:
		return -(x + 1) // 2
for a0 in range(int(input())):
	(a, b) = list(map(int, input().split()))
	print(ans(b) - ans(a - 1))


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


def calc(x):
	if x % 2 == 0:
		return x / 2
	else:
		return calc(x - 1) - x
q = int(input())
for _ in range(q):
	(*a,) = map(int, input().split())
	(l, r) = (a[0], a[1])
	print(int(calc(r) - calc(l - 1)))


def func():
	(l, r) = input().split(' ')
	(l, r) = (int(l), int(r))
	l_num = l * (-1) ** l
	flag = l_num > 0
	if not (r - l) % 2:
		if flag:
			print(l_num + (r - l) // 2)
		else:
			print(l_num - (r - l) // 2)
	elif flag:
		print(-1 * ((r - l) // 2 + 1))
	else:
		print((r - l) // 2 + 1)
n = int(input())
for _ in range(n):
	func()


n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	m = r // 2
	if r % 2:
		m -= r
	l -= 1
	k = l // 2
	if l % 2:
		k -= l
	print(m - k)


q = int(input())

def fasthash(i):
	if i % 2 == 0:
		return i // 2
	return -(i + 1) // 2
for i in range(q):
	(l, r) = [int(i) for i in input().split()]
	print(fasthash(r) - fasthash(l - 1))


x = int(input())
for i in range(x):
	(a, b) = map(int, input().split())
	if a % 2 == 1 and b % 2 == 1:
		t = (b - a) // 2
		print(t * (a + b) - (t + 1) * (a + b) + (a + b) // 2)
	elif a % 2 == 0 and b % 2 == 0:
		t = (b - a) // 2
		print((t + 1) * (a + b) - t * (a + b) - (a + b) // 2)
	elif a % 2 == 1 and b % 2 == 0:
		t = (b - a + 1) // 2
		print(-t * (a + b - 1) // 2 + t * (a + b + 1) // 2)
	elif a % 2 == 0 and b % 2 == 1:
		t = (b - a + 1) // 2
		print(t * (a + b - 1) // 2 - t * (a + b + 1) // 2)


def pat(r):
	if r % 2 == 0:
		o = r // 2
	else:
		o = r // 2 + 1
	s1 = o + o * (o - 1)
	s = r * (r + 1) // 2
	s -= 2 * s1
	return s
n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	a = pat(r)
	if l > 1:
		a -= pat(l - 1)
	print(a)


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) = map(int, input().split())
	print(getsum(R) - getsum(L - 1))
	Q -= 1


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(l, r) = list(map(int, input().split()))
	ans = (r - l + 1) // 2
	if l % 2 == 0:
		ans *= -1
	if (r - l + 1) % 2 == 1:
		ans += r * (-1) ** r
	print(ans)


q = int(input())

def od(x):
	r = (x - 1) // 2 - x
	return r

def ev(x):
	r = x // 2
	return r
while q > 0:
	s = 0
	(n, k) = map(int, input().split())
	if k % 2 == 0:
		q1 = ev(k)
	else:
		q1 = od(k)
	if (n - 1) % 2 == 0:
		q2 = ev(n - 1)
	else:
		q2 = od(n - 1)
	print(q1 - q2)
	q = q - 1


def d(n):
	if n % 2 == 0:
		return n / 2
	else:
		return -(n // 2 + 1)
t = int(input())
while t > 0:
	(l, r) = [int(i) for i in input().split()]
	print(int(d(r) - d(l - 1)))
	t -= 1


for i in range(int(input())):
	(l, r) = 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)


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


from math import ceil, floor
t = int(input())
for i in range(t):
	(l, r) = map(int, input().split())
	if l % 2 == 1:
		l *= -1
	if r % 2 == 1:
		r *= -1
	ans = (l + r) / 2
	if ans > 0:
		print(ceil(ans))
	else:
		print(floor(ans))


q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	x = 0
	if l % 2 != 0 or r % 2 != 0:
		x = 1
	o = (r - l) // 2 + x
	e = r - l + 1 - o
	if l % 2 == 0:
		h1 = e * (2 * l + (e - 1) * 2) // 2
		h2 = o * (2 * (l + 1) + (o - 1) * 2) // 2
		print(int(h1 - h2))
	elif l % 2 != 0:
		h1 = e * (2 * (l + 1) + (e - 1) * 2) // 2
		h2 = o * (2 * l + (o - 1) * 2) // 2
		print(int(h1 - h2))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print((-1) ** n * n)
	elif n % 2 != 0:
		if k % 2 == 0:
			sum = (k + 1 - n) // 2
			print(sum)
		else:
			sum = (k - n + 1) // 2 - k
			print(sum)
	elif k % 2 == 0:
		sum = -1 * (k - n) // 2 + k
		print(sum)
	else:
		sum = -1 * (k - n + 1) // 2
		print(sum)


import math
from decimal import Decimal
import heapq

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	if r % 2 == 0:
		r1 = r // 2
	else:
		r1 = (r - 1) // 2 - r
	l -= 1
	if l % 2 == 0:
		l1 = l // 2
	else:
		l1 = (l - 1) // 2 - l
	print(r1 - l1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	even = 0
	odd = 0
	x1 = (a if a % 2 == 1 else a + 1) - 2
	y1 = b if b % 2 == 1 else b - 1
	n11 = (1 + y1) // 2
	n12 = (1 + x1) // 2
	odd = n11 * n11 - n12 * n12
	x2 = (a if a % 2 == 0 else a + 1) - 2
	y2 = b if b % 2 == 0 else b - 1
	n21 = y2 // 2
	n22 = x2 // 2
	even = n21 * (n21 + 1) - n22 * (n22 + 1)
	print(even - odd)


q = int(input())
while q > 0:
	(l, r) = [int(x) for x in input().split()]
	if (l + r) % 2 == 0:
		if l % 2 == 0:
			print((l + r) // 2)
		else:
			print(-((l + r) // 2))
	elif l % 2 == 1 and r % 2 == 1:
		print((r - l) // 2 + 1)
	elif r % 2 == 1:
		print(-((r - l) // 2 + 1))
	else:
		print((r - l) // 2 + 1)
	q -= 1


from math import ceil

def ind(n):
	return (-1) ** (n % 2) * ceil(n / 2)
q = int(input())
for i in range(q):
	suma = 0
	(l, r) = map(int, input().split())
	print(ind(r) - ind(l - 1))


q = int(input())
for query in range(q):
	(x, y) = map(int, input().split(' '))
	sol = 0
	if x % 2:
		if y % 2:
			sol -= y
		sol += (y - x + 1) // 2
	else:
		if y % 2 == 0:
			sol += y
		sol -= (y - x + 1) // 2
	print(sol)


n = int(input())
for x in range(n):
	(l, r) = list(map(int, input().split()))
	if l % 2 != 0 and r % 2 == 0:
		pa = r - l + 1
		ta = pa // 2
		print(ta)
	elif l % 2 == 0 and r % 2 == 0:
		pa = r - l
		ta = pa // 2
		print(ta + l)
	elif l % 2 != 0 and r % 2 != 0:
		pa = r - l
		ta = pa // 2
		print(ta - r)
	else:
		pa = r - l - 1
		ta = pa // 2
		print(ta + l - r)


for _ in range(int(input())):
	(l, r) = list(map(int, input().split()))
	l -= 1
	sum_r = r // 2 * (r // 2 + 1) - (r * (r + 1) // 2 - r // 2 * (r // 2 + 1))
	sum_l = l // 2 * (l // 2 + 1) - (l * (l + 1) // 2 - l // 2 * (l // 2 + 1))
	print(sum_r - sum_l)


def func(x):
	if x & 1:
		return -(x + 1) // 2
	else:
		return x // 2
q = int(input())
for i in range(q):
	(a, b) = map(int, input().split())
	print(int(func(b)) - func(a - 1))


import math

def Present():
	q = int(input())
	for i in range(q):
		(l, r) = map(int, input().split())
		if l % 2 != 0 and r % 2 != 0:
			value = (r - l) / 2
			value -= r
		elif l % 2 == 0 and r % 2 != 0:
			value = (r - l) // 2
			value += l - r
		elif l % 2 != 0 and r % 2 == 0:
			value = (r - l) // 2
			value += 1
		else:
			value = (r - l) / 2
			value += l
		print(int(value))
Present()


from sys import stdin, stdout
q = int(stdin.readline().strip())
for _ in range(q):
	(l, r) = list(map(int, stdin.readline().strip().split()))
	ans = 0
	if l % 2 == 0:
		if r % 2 == 0:
			ans = -1 * ((r - l) // 2) + r
		else:
			ans = -1 * ((r - l + 1) // 2)
	elif r % 2 == 0:
		ans = (r - l + 1) // 2
	else:
		ans = (r - l) // 2 - r
	stdout.write(str(ans) + '\n')


import sys, math

def mp():
	return list(map(int, input().split()))

def ss(x):
	return x * (x + 1) // 2

def sol(x):
	if x == 0:
		return 0
	res = ss(x // 2) * 2
	res1 = ss(x) - res
	return res - res1

def main():
	q = int(input())
	for i in range(q):
		(l, r) = mp()
		print(sol(r) - sol(l - 1))
debug = 0
if debug:
	file = open('input.txt', 'r')
	input = file.readline
main()
if debug:
	file.close()


import sys
import string
from math import gcd
import getpass
import math
from decimal import Decimal
import pprint

def ria():
	return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')

def sumFor(a):
	return (1 + a) * a // 2

def getPos(a):
	return sumFor(a) * 2 + 2 * (a + 1)

def getNeg(a):
	return sumFor(a) * -2 - 1 * (a + 1)
q = ria()[0]
for i in range(q):
	(l, r) = ria()
	print(getNeg((r + 1) // 2 - 1) - getNeg(l // 2 - 1) + getPos(r // 2 - 1) - getPos((l - 1) // 2 - 1))


import math
n = input()
for i in range(int(n)):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	print(math.ceil(b / 2) * (-1) ** b - math.ceil(a / 2) * (-1) ** a + a * (-1) ** a)


import math
n = int(input())
Result = []
for i in range(0, n):
	List = list(map(int, input().strip().split()))[0:2]
	low = List[0]
	high = List[1]
	AccumulatedSumFrom_1_to_high = (-1) ** high * math.ceil(high / 2)
	AccumulatedSumFrom_1_to_low = (-1) ** (low - 1) * math.ceil((low - 1) / 2)
	Result.append(AccumulatedSumFrom_1_to_high - AccumulatedSumFrom_1_to_low)
for i in Result:
	print(i)


import sys

def f(l, r):
	nn = r - l + 1
	if nn % 2 == 0:
		if l % 2 == 1:
			return nn // 2
		else:
			return -(nn // 2)
	elif l % 2 == 1:
		return nn // 2 - r
	else:
		return -(nn // 2) + r
q = int(input())
for _ in range(q):
	(l, r) = map(int, input().split())
	print(f(l, r))


def count(n):
	return (n + 1) // 2 * (-1 if n % 2 else 1)
for i in range(int(input())):
	(x, y) = map(int, input().split())
	print(count(y) - count(x - 1))


q = int(input())
for i in range(q):
	arr = [int(x) for x in input().split()]
	a = arr[0]
	b = arr[1]
	c = b - a
	if b % 2 == 1:
		if c % 2 == 0:
			print(c // 2 - b)
		elif c % 2 == 1:
			print(a + c // 2 - b)
	elif b % 2 == 0:
		if c % 2 == 0:
			print(b - c // 2)
		elif c % 2 == 1:
			print(b - c // 2 - a)


import math
q = int(input())

def s(n):
	return int(n * (n + 1)) >> 1

def even(n):
	return s(n >> 1) << 1

def odd(n):
	n = n + 1 >> 1
	return (s(n - 1) << 1) + n

def ts(n):
	return even(n) - odd(n)
for i in range(q):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	print(ts(b) - ts(a - 1))


n = int(input())
ans = 0
for i in range(n):
	(l, r) = map(int, input().strip().split())
	odd_l = l + 1 if l % 2 == 0 else l
	odd_r = r - 1 if r % 2 == 0 else r
	even_l = l if l % 2 == 0 else l + 1
	even_r = r if r % 2 == 0 else r - 1
	n_odd = 1 + (odd_r - odd_l) // 2
	n_even = 1 + (even_r - even_l) // 2
	sum_even = (even_l + even_r) // 2 * n_even
	sum_odd = (odd_l + odd_r) // 2 * n_odd
	print(sum_even - sum_odd)


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	for _ in range(int(input())):
		(l, r) = inar()
		even = 0
		odd = 0
		if r % 2 == 0:
			odd = (r // 2) ** 2
		else:
			odd = (r // 2 + 1) ** 2
		even = r // 2 * (r // 2 + 1)
		target = even - odd
		if (l - 1) % 2 == 0:
			odd = ((l - 1) // 2) ** 2
		else:
			odd = ((l - 1) // 2 + 1) ** 2
		even = (l - 1) // 2 * ((l - 1) // 2 + 1)
		ans = target - (even - odd)
		print(ans)
main()


t = int(input())
for i in range(t):
	s = input()
	s = s.split()
	for j in range(len(s)):
		s[j] = int(s[j])
	l = s[0]
	r = s[1]
	res = 0
	if l == r:
		print((-1) ** l * l)
	else:
		if l % 2 == 0:
			res = res + l
			l = l + 1
		if r % 2 == 1:
			res = res - r
			r = r - 1
		if l == r:
			res = res + (-1) ** l * l
		elif r > 1:
			d = (r - l + 1) // 2
			res = res + d
		print(res)


def oddSum(n):
	return n * n

def evenSum(n):
	return n * (n + 1)

def findSum(num):
	if num <= 0:
		return 0
	n_terms = num // 2
	if num % 2 != 0:
		n_terms += 1
		return oddSum(n_terms) * -1
	return evenSum(n_terms)
for _ in range(int(input())):
	(start, stop) = map(int, input().split())
	total_sum = findSum(stop) + findSum(stop - 1)
	remove_sum = findSum(start - 1) + findSum(start - 2)
	required_sum = total_sum - remove_sum
	print(required_sum)


print('\n'.join([(lambda l, r: str((r // 2 if not r % 2 else -1 * (r + 1) // 2) - ((l - 1) // 2 if not (l - 1) % 2 else -1 * l // 2)))(*map(int, input().split())) for i in range(int(input()))]))


def f(b):
	if b % 2 == 0:
		return b
	return -b
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	k = 1
	if a % 2 == 0:
		k = -1
	if (b - a) % 2 == 0:
		print(int(k * (b - a) / 2 + f(b)))
	else:
		print(int(k * (b - a + 1) / 2))


n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	s = r // 2
	if r % 2:
		s -= r
	l -= 1
	sl = l // 2
	if l % 2:
		sl -= l
	print(s - sl)


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


def find(l, r):
	l = l - 1
	if l % 2 != 0:
		lsum = -1 * (abs(l) + 1) // 2
	else:
		lsum = l // 2
	if r % 2 != 0:
		rsum = -1 * (abs(r) + 1) // 2
	else:
		rsum = r // 2
	print(rsum - lsum)

def main():
	n = int(input())
	for _ in range(n):
		(l, r) = map(int, input().split())
		find(l, r)
main()


def sumall(n):
	return n * (n + 1) // 2

def sumeven(n):
	return n * n + n

def sumodd(n):
	return n * n
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	len = (r - l + 1) // 2
	if l % 2 == 1:
		tot = sumall(r) - sumall(l - 1)
		odds = (r - l) // 2 + 1
		st = l // 2 + 1
		remsum = sumodd(st + odds - 1) - sumodd(st - 1)
		print(tot - 2 * remsum)
	else:
		tot = sumall(r) - sumall(l - 1)
		odds = (r - l + 1) // 2
		st = l // 2 + 1
		remsum = sumodd(st + odds - 1) - sumodd(st - 1)
		print(tot - 2 * remsum)


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


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


n = int(input())

def f(x):
	if x % 2:
		return -1 * (x + 1) // 2
	return x // 2
for i in range(n):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


case = int(input())
for _ in range(case):
	(le, ri) = map(int, input().split())
	if le == ri:
		print(le * (-1) ** le)
	else:
		lm2 = le % 2
		rm2 = ri % 2
		rit = ri * (-1) ** ri
		if lm2 + rm2 == 0:
			ans = int((ri - le) / 2) * -1 + rit
		elif lm2 + rm2 == 2:
			ans = int((ri - le) / 2) + rit
		elif lm2 == 1 and rm2 == 0:
			ans = int((ri - le) / 2) + 1
		elif lm2 == 0 and rm2 == 1:
			ans = (int((ri - le) / 2) + 1) * -1
		print(ans)


def main():
	n = int(input())
	for i in range(n):
		(s, p) = [int(v) for v in input().split()]
		if s % 2 == 0 and p % 2 != 0:
			print(-1 * (p - s + 1) // 2)
		elif s % 2 == 0 and p % 2 == 0:
			print(-1 * (p - s) // 2 + p)
		elif s % 2 != 0 and p % 2 == 0:
			print(1 * (p - s + 1) // 2)
		elif s % 2 != 0 and p % 2 != 0:
			print(1 * (p - s) // 2 - p)
main()


def sumtill(n):
	if n % 2 == 0:
		return n // 2
	else:
		return -1 * n + (n - 1) // 2
q = int(input())
for you in range(q):
	l = input().split()
	print(-1 * sumtill(int(l[0]) - 1) + sumtill(int(l[1])))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	n = (b - a + 1) // 2
	s = 0
	if a % 2 == 1:
		s += n
	else:
		s += n * -1
	n *= 2
	if n != b - a + 1:
		if a % 2 == 0:
			s += b
		else:
			s += b * -1
	print(s)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 1:
		print((b - a + 1) // 2 * pow(-1, b))
	else:
		print((b - (b - a) // 2) * pow(-1, b))


n = int(input())
for i in range(0, n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if int(a) % 2 != 0 and int(b) % 2 != 0:
		print(int((-a - b) / 2))
	elif int(a) % 2 == 0 and int(b) % 2 == 0:
		print(int((b + a) / 2))
	elif int(a) % 2 != 0 and int(b) % 2 == 0:
		print(int((b - a + 1) / 2))
	else:
		print(int((a - b - 1) / 2))


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)


from sys import stdin
q = int(stdin.readline())
for _ in range(q):
	(l, r) = map(int, stdin.readline().split(' '))
	k = (r - l + 1) // 2
	print(k * (-1 if l % 2 == 0 else 1) + r * (-1) ** r * (1 if (r - l) % 2 == 0 else 0))


n = int(input())
s = lambda x: -((x + 1) // 2) if x & 1 else x // 2
for i in range(n):
	(x, y) = map(int, input().split())
	print(s(y) - s(x - 1))


q = input()
q = int(q)

def read_ints():
	return list(map(int, input().split()))
i = 0
ans = []
while i < q:
	i += 1
	(l, r) = read_ints()
	x = r - l + 1
	if x % 2 == 0:
		if l % 2 == 0:
			ans.append(int(-x / 2))
		else:
			ans.append(int(x / 2))
	elif l % 2 == 0:
		ans.append(int(l / 2 + r / 2))
	else:
		ans.append(int(-(l / 2 + r / 2)))
else:
	for k in ans:
		print(k)


def solve(l, r):
	distance = r - l + 1
	s = distance // 2
	if distance % 2 != 0:
		s -= r
	return s if l % 2 != 0 else -s

def main():
	n_queries = int(input())
	for _ in range(n_queries):
		[l, r] = [int(_) for _ in input().split()]
		print(solve(l, r))
main()


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)
threading.stack_size(2 ** 27)
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, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

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):
	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):
	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():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = True
testingMode = False
optimiseForReccursion = False

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)
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()


def BestPresent(num1, num2):
	if (num2 - num1) % 2 == 0:
		return num1 * (-1) ** num1 + (num2 - num1) / 2 * (-1) ** num2
	else:
		return (num2 - num1 + 1) / 2 * (-1) ** num2
for i in range(int(input())):
	(x, y) = map(int, input().split())
	print(int(BestPresent(x, y)))


import sys
input = sys.stdin.readline

def main():
	q = int(input())
	for i in range(q):
		(l, r) = map(int, input().split())
		if l % 2 == 0 and r % 2 == 0 or (l % 2 != 0 and r % 2 != 0):
			if l % 2 == 0:
				print((l + r) // 2)
			else:
				print((-l - r) // 2)
		elif l % 2 == 0 and r % 2 != 0:
			print((l - r - 1) // 2)
		else:
			print((-l + r + 1) // 2)
	return
main()


q = int(input())
for i in range(q):
	entrada = input()
	entrada = [int(x) for x in entrada.split()]
	l = entrada[0]
	r = entrada[1]
	result = 0
	if l % 2 == 0:
		if r % 2 == 0:
			result = int((r - l) / 2) + l
		else:
			result = -int((r - l + 1) / 2)
	elif r % 2 == 0:
		result = int((r - l + 1) / 2)
	else:
		result = int((r - l) / 2) - r
	print(result)


q = int(input())
res = []

def sum_chet(l, r):
	if l % 2 != 0:
		l += 1
	if r % 2 != 0:
		r -= 1
	return (l + r) * (r - l + 2) // 4

def sum_nechet(l, r):
	if l % 2 == 0:
		l += 1
	if r % 2 == 0:
		r -= 1
	return (l + r) * (r - l + 2) // 4
for i in range(q):
	(l, r) = map(int, input().split())
	res.append(sum_chet(l, r) - sum_nechet(l, r))
for item in res:
	print(item)


t = int(input())
for i in range(t):
	(x, r) = [int(x) for x in input().split()]
	a = x * pow(-1, x)
	b = r * pow(-1, r)
	if a < 0 and b < 0:
		c = (r - x + 1) // 2
		sum1 = (c + 1) * (a + b) // 2
		sum2 = c * (-a + 1 - b - 1) // 2
		print(sum1 + sum2)
	elif a < 0 and b > 0:
		c = (r - x + 1) // 2
		sum1 = c * (a - (b - 1)) // 2
		sum2 = c * (-a + 1 + b) // 2
		print(sum1 + sum2)
	elif a > 0 and b < 0:
		c = (r - x + 1) // 2
		sum1 = c * (a + (-b - 1)) // 2
		sum2 = c * (-a - 1 + b) // 2
		print(sum1 + sum2)
	elif a > 0 and b > 0:
		c = (r - x + 1) // 2
		sum1 = (c + 1) * (a + b) // 2
		sum2 = c * (-a - 1 - b + 1) // 2
		print(sum1 + sum2)


import math
q = int(input())

def cur(i):
	return i if i % 2 == 0 else -i
sign = lambda x: (1, -1)[x < 0]
for i in range(q):
	(l, r) = [int(t) for t in input().split()]
	curl = cur(l)
	signl = sign(curl)
	if r == l:
		print(curl)
	elif (r - l + 1) % 2 == 0:
		temp = -signl
		print((r - l + 1) // 2 * temp)
	else:
		temp = (r - l) // 2 * -signl
		print(temp + cur(r))


def prefix_sum(x):
	if x % 2:
		return (x + 1) // 2 * -1
	return x // 2
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	s1 = prefix_sum(r)
	s2 = prefix_sum(l - 1)
	ans = s1 - s2
	print(ans)


for _ in range(int(input())):
	(l, r) = input().split()
	(l, r) = (int(l), int(r))
	if l & 1 and r & 1:
		ans = (r - l) // 2 - r
	elif not l & 1 and (not r & 1):
		ans = (r - l) // 2 * -1 + r
	elif l & 1 and (not r & 1):
		ans = (r - l + 1) // 2
	else:
		ans = (r - l + 1) // 2 * -1
	print(ans)


from sys import stdin

def main():
	Q = int(input())
	LR = [tuple(map(int, input().split())) for _ in [0] * Q]
	for (l, r) in LR:
		n = r - l + 1
		x = (l + r) * n // 2
		m = (n + 1) // 2
		if l % 2:
			odd = (2 * l + (m - 1) * 2) * m // 2 * -1
			even = x + odd
		else:
			even = (2 * l + (m - 1) * 2) * m // 2
			odd = even - x
		print(even + odd)
input = lambda : stdin.readline()
main()


def calculate(indexb, indexe):
	result = 0
	halfsize = int((indexe - indexb + 1) / 2)
	result += halfsize
	if indexb % 2 == 0:
		result = result * -1
	if (indexe - indexb + 1) % 2 == 1:
		if indexe % 2 == 0:
			result += indexe
		else:
			result += indexe * -1
	return result
t = int(input())
for i in range(t):
	(indexb, indexe) = map(int, input().split())
	print(calculate(indexb, indexe))


import math
q = int(input())
for i in range(q):
	(l, r) = [int(v) for v in input().split()]
	new_l = l / 2
	new_r = r / 2
	if l % 2:
		new_l = new_l * -1
	if r % 2 == 1:
		new_r = new_r * -1
	result = new_l + new_r
	if result < 0:
		result = math.floor(result)
	else:
		result = math.ceil(result)
	print(result)


import logging, sys
logging.basicConfig(level=logging.INFO)

def solve(x):
	if x % 2 == 0:
		return int(x / 2)
	else:
		return int(x // 2 - x)

def main():
	q = int(sys.stdin.readline())
	while q > 0:
		q -= 1
		(l, r) = map(int, sys.stdin.readline().split())
		print(solve(r) - solve(l - 1))
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
main()


import math
q = int(input())
l = []
r = []
for i in range(q):
	linri = input().split(' ')
	li = int(linri[0]) - 1
	ri = int(linri[1])
	l.append(li)
	r.append(ri)

def come_get_sum(el, ar):
	if (ar - el) % 2 == 0:
		return (ar - el) / 2 * math.pow(-1, el)
	elif (ar - el) % 2 != 0:
		first = (el + 1) * math.pow(-1, el + 1)
		second = come_get_sum(el + 1, ar)
		return first + second
for i in range(q):
	print(int(come_get_sum(l[i], r[i])))


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) = map(int, input().split())
		print(calc(b) - calc(a - 1))
main()


n = int(input())
i = 0
while i < n:
	(l, r) = map(int, input().split())
	sum = 0
	if l == r:
		if l % 2 == 0:
			print(l)
		else:
			print(-1 * l)
		i += 1
		continue
	if l % 2 == 0:
		sum += l
		l += 1
	if r % 2 != 0:
		sum -= r
		r -= 1
	if r >= l:
		print(int(sum + (r - l + 1) / 2))
	else:
		print(int(sum))
	i += 1


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


def program():
	(l, r) = map(int, input().split())
	if l % 2 == 0 and r % 2 == 0:
		a = (l + r) // 2
	elif l % 2 != 0 and r % 2 != 0:
		a = -(l + r) // 2
	elif l % 2 != 0 and r % 2 == 0:
		a = (r - l) // 2 + 1
	else:
		a = -((r - l) // 2 + 1)
	print(a)
t = int(input())
for i in range(t):
	program()


for _numQ in range(int(input())):
	(first, last) = [int(s) for s in input().split()]
	evenLen = False
	if first % 2 != last % 2:
		origZeroElem = first
		first += 1
		evenLen = True
	sumX = (first + last) // 2
	if first % 2:
		sumX = 0 - sumX
	if evenLen:
		if origZeroElem % 2:
			sumX -= origZeroElem
		else:
			sumX += origZeroElem
	print('{}'.format(sumX))


qs = int(input())

def sum_i(n):
	return (n + 1) // 2 * (-1 if n % 2 else 1)
for q in range(qs):
	(l, r) = map(int, input().split(' '))
	print(sum_i(r) - sum_i(l - 1))


def s(n):
	return (1 + n) // 2 * (-1 if n % 2 == 1 else 1)
for _ in range(int(input())):
	(l, r) = map(int, input().split(' '))
	print(s(r) - s(l - 1))


import math
q = int(input())
a = []
total_sum = 0
for i in range(q):
	x = list(map(int, input().split()))
	total_sum = 0
	if x[0] % 2 == 0 and x[-1] % 2 == 0:
		total_sum = (x[0] + x[-1]) // 2
	elif x[0] % 2 == 0 and x[-1] % 2 != 0:
		total_sum = math.ceil((x[-1] - x[0]) / 2) * -1
	elif x[0] % 2 != 0 and x[-1] % 2 == 0:
		total_sum = math.ceil((x[-1] - x[0]) / 2)
	elif x[0] % 2 != 0 and x[-1] % 2 != 0 and (x[0] != x[-1]):
		total_sum = (x[-1] - (x[-1] - x[0]) // 2) * -1
	elif x[0] % 2 != 0 and x[-1] % 2 != 0 and (x[0] == x[-1]):
		total_sum = -x[0]
	a.append(total_sum)
for j in range(len(a)):
	print(a[j])


n = int(input())
for i in range(n):
	(l, r) = list(map(int, input().split()))
	if l % 2 != 0:
		odd = l
		even = l + 1
	else:
		odd = l + 1
		even = l
	if r % 2 == 0:
		ev = r
		od = r - 1
	else:
		od = r
		ev = r - 1
	ne = (ev - even) // 2
	ne += 1
	no = (od - odd) // 2
	no += 1
	if l == r and l % 2 == 0:
		no = 0
	if l == r and l % 2 != 0:
		ne = 0
	if l % 2 == 0 and r % 2 == 0:
		print(r - no)
	elif l % 2 == 0 and r % 2 != 0:
		print(-no)
	elif l % 2 != 0 and r % 2 == 0:
		print(ne)
	else:
		print(-r + ne)


q = int(input())
while q > 0:
	(l, r) = [int(i) for i in input().split()]
	if l == r:
		if l % 2 == 1:
			print(-1 * l)
		else:
			print(l)
	else:
		len = r - l + 1
		if len % 2 == 0:
			if l % 2 == 0:
				print(len // 2 * -1)
			else:
				print(len // 2)
		else:
			ans = len // 2 + l
			if l % 2 == 0:
				print(ans)
			else:
				print(-1 * ans)
	q -= 1


from sys import stdin

def sum(n):
	if n < 1:
		return 0
	temp = int((n + 1) / 2)
	if n % 2 != 0:
		temp = temp * -1
	return temp
firstLine = stdin.readline()
if len(firstLine) < 2:
	print('Invalid Input')
else:
	queries = int(firstLine)
arr = []
for i in range(0, queries):
	arr.append([int(x) for x in stdin.readline().split()])
for i in range(0, queries):
	answer = sum(arr[i][1]) - sum(arr[i][0] - 1)
	print(answer)


class Present:
	q = int(input())
	s = 0
	l = 0
	r = 0
	for i in range(q):
		aux = [int(x) for x in input().split()]
		l = aux[0]
		r = aux[1]
		if l % 2 == 1 and r % 2 == 1:
			s = -1 * ((l - r) // 2 + r)
		elif l % 2 == 1 and r % 2 == 0:
			s = (r - l + 1) // 2
		elif l % 2 == 0 and r % 2 == 0:
			s = (l - r) // 2 + r
		else:
			s = -1 * (r - l + 1) // 2
		print(s)


def s(l, r):
	n = int((r - l) / 2 + 1)
	return n * (l + n - 1)
for _ in range(int(input())):
	(l, r) = [int(j) for j in input().split()]
	(even, odd) = (0, 0)
	if l % 2 == 0:
		even = s(l, r)
		odd = s(l + 1, r)
	else:
		even = s(l + 1, r)
		odd = s(l, r)
	print(even - odd)


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_a(tp):
	return list(r_t(tp))

def S(n):
	return n // 2 if not n & 1 else S(n - 1) - n

def main():
	q = int(r())
	for _ in range(q):
		(a, b) = r_t(int)
		print(S(b) - S(a - 1))
main()


q = int(input())
for i in range(0, q):
	(s1, s2) = map(int, input().split())
	if s1 % 2 == 0 and s2 % 2 == 0:
		print(int(-(s2 - s1) / 2 + s2))
	elif s1 % 2 != 0 and s2 % 2 == 0:
		print(int((s2 - s1 + 1) / 2))
	elif s1 % 2 == 0 and s2 % 2 != 0:
		print(int(-(s2 - s1 + 1) / 2))
	elif s1 % 2 != 0 and s2 != 0:
		print(int((s2 - s1) / 2 - s2))


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


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


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


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


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)


n = int(input())

def func(x, y):
	k = y - x + 1
	t = k // 2
	if x % 2 == 0:
		if k % 2 == 0:
			print(-t)
		else:
			print(-t + y)
	elif k % 2 == 0:
		print(t)
	else:
		print(t - y)
for i in range(n):
	s = input().split()
	(x, y) = (int(s[0]), int(s[1]))
	func(x, y)


def F(x):
	if x % 2 == 0:
		return x // 2
	else:
		return -x + F(x - 1)

def sol():
	t = int(input())
	for _ in range(t):
		(l, r) = map(int, input().split())
		print(F(r) - F(l - 1))
sol()


def f(n):
	return n * (-1) ** (n % 2)
q = int(input())
for _ in ' ' * q:
	(l, r) = map(int, input().split())
	if l == r:
		print(f(l))
	else:
		if l % 2 == 0 and r % 2 != 0:
			s = -1 * ((r - l + 1) // 2)
		elif l % 2 == 0 and r % 2 == 0:
			s = -1 * ((r - 1 - l + 1) // 2) + f(r)
		elif l % 2 != 0 and r % 2 == 0:
			s = 1 * ((r - l + 1) // 2)
		elif l % 2 != 0 and r % 2 != 0:
			s = 1 * ((r - 1 - l + 1) // 2) + f(r)
		print(s)


a = int(input())
r1 = r2 = l1 = l2 = 0
for i in range(a):
	(l, r) = map(int, input().split())
	if r % 2 == 1:
		r1 = int(r / 2) + 1
		r2 = int(r / 2)
	else:
		r1 = r2 = int(r / 2)
	if l % 2 == 0:
		l1 = int(l / 2)
		l2 = int(l / 2) - 1
	else:
		l1 = l2 = int(l / 2)
	a = -r1 ** 2 + r2 * (r2 + 1)
	b = -l1 ** 2 + l2 * (l2 + 1)
	print(a - b)


q = int(input())
for _ in range(q):
	(l, r) = map(int, input().split())
	if l % 2 == 0:
		tmp = -1
	else:
		tmp = 1
	cnt = r - l + 1
	result = cnt // 2 * tmp
	if cnt % 2 != 0:
		result += r if r % 2 == 0 else -r
	print(result)


def inint():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def sum1(a):
	no = a // 2
	ne = a // 2
	if a % 2 != 0:
		no += 1
	return -no * (no + 1) + no + ne * (ne + 1)

def main():
	for _ in range(inint()):
		(l, r) = inlist()
		sm = sum1(r) - sum1(l - 1)
		print(sm)
main()


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
q = int(input())
while q:
	q -= 1
	(l, r) = map(int, input().split())
	if l == r:
		if l % 2:
			print(-l)
		else:
			print(l)
	elif l % 2 and r % 2:
		print((r - l) // 2 - r)
	elif l % 2 == 0 and r % 2 == 0:
		print(r - (r - l) // 2)
	elif l % 2 == 1 and r % 2 == 0:
		print((r + 1 - l) // 2)
	else:
		print(-((r - 1 - l) // 2 + 1))


from sys import stdin
sum_ = lambda a, b: b * (b + 1) // 2 - a * (a - 1) // 2 - 2 * ((b - (1 - b % 2) + 1) // 2) ** 2 + 2 * ((max(0, a - 1 - a % 2) + 1) // 2) ** 2
print('\n'.join(map(str, list(map(lambda z: sum_(*z), list(map(lambda x: tuple(map(int, x.split())), stdin.readlines()[1:])))))))


import sys

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

def psum(i):
	return (-1) ** i * ((i + 1) // 2)
q = int(input())
for i in range(q):
	(l, r) = rint()
	print(psum(r) - psum(l - 1))


cs = int(input())
for c in range(cs):
	(l, r) = map(int, input().split())
	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 math
q = int(input())
for i in range(q):
	ans1 = 0
	ans2 = 0
	(l, r) = [int(x) for x in input().split()]
	mid = r - l + 1
	if mid == 1:
		ans1 = mid * (2 * l + (mid - 1) * 2) // 2
		if l & 1:
			ans1 = -ans1
	elif mid & 1:
		mid = math.ceil(mid / 2)
		if l & 1:
			ans1 = -(mid * (2 * l + (mid - 1) * 2) // 2)
			ans2 = (mid - 1) * (2 * (l + 1) + (mid - 2) * 2) // 2
		else:
			ans1 = mid * (2 * l + (mid - 1) * 2) // 2
			ans2 = -((mid - 1) * (2 * (l + 1) + (mid - 2) * 2)) // 2
	else:
		mid = mid // 2
		if l & 1:
			ans1 = -(mid * (2 * l + (mid - 1) * 2) // 2)
			ans2 = mid * (2 * (l + 1) + (mid - 1) * 2) // 2
		else:
			ans1 = mid * (2 * l + (mid - 1) * 2) // 2
			ans2 = -(mid * (2 * (l + 1) + (mid - 1) * 2)) // 2
	print(ans1 + ans2)


def run():
	n = int(input())
	for t in range(n):
		(l, r) = map(int, input().split())
		leven = l if l % 2 == 0 else l + 1
		reven = r if r % 2 == 0 else r - 1
		alloverall = r * (r + 1) // 2
		leftoverall = (l - 1) * l // 2
		overall = alloverall - leftoverall
		alloverallEven = reven * (reven + 2) // 4
		leftoverallEven = (leven - 2) * leven // 4
		overalleven = alloverallEven - leftoverallEven
		overallodd = -(overall - overalleven)
		print(overalleven + overallodd)
run()


q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	le = l + l % 2
	re = r - r % 2
	e = (le + re) * ((re - le) // 2 + 1) // 2
	lo = l + (1 - l % 2)
	ro = r - (1 - r % 2)
	o = (lo + ro) * ((ro - lo) // 2 + 1) // 2
	print(e - o)


def sum(a, d, r, n):
	s = 0
	s += a / (1 - r)
	s += d * r * (1 - pow(r, n - 1)) / pow(1 - r, 2)
	s -= (a + (n - 1) * d) * pow(r, n) / (1 - r)
	return s
n = int(input())
for i in range(n):
	num = list(map(int, input().split()))
	a = -1
	d = -1
	r = -1
	s2 = sum(a, d, r, num[1])
	s1 = sum(a, d, r, num[0] - 1)
	print(int(s2 - s1))


import math as m

def agp(n):
	return int((n - 1) * m.pow(-1, n + 1) / 2 - (1 - m.pow(-1, n - 1)) / 4)
n = int(input())
a = []
for z in range(n):
	s = input()
	t = s.split()
	(x, y) = (int(t[0]), int(t[1]))
	v = agp(y + 1) - agp(x)
	a.append(v)
for i in a:
	print(i)


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


import math as ma
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	se = 0
	ee = 0
	so = 0
	eo = 0
	if a % 2 == 0:
		se = a
		so = a + 1
	else:
		se = a + 1
		so = a
	if b % 2 == 0:
		ee = b
		eo = b - 1
	else:
		ee = b - 1
		eo = b
	so = -ma.ceil((eo - so + 1) / 2) * (2 * so + 2 * (ma.ceil((eo - so + 1) / 2) - 1))
	se = ma.ceil((ee - se + 1) / 2) * (2 * se + 2 * ma.ceil((ee - se + 1) / 2 - 1))
	print(int((se + so) // 2))


n = int(input())
for jj in range(n):
	(r, l) = map(int, input().split())
	le = l - r + 1
	pe = le // 2
	if le % 2 == 0:
		if r % 2 == 0:
			su = -1 * pe
			print(su)
		else:
			su = 1 * pe
			print(su)
	elif r % 2 == 0:
		su = -1 * pe + l
		print(su)
	else:
		su = 1 * pe - l
		print(su)


n = int(input())
for i in range(n):
	a = []
	a = input().split()
	l = int(a[0])
	r = int(a[1])
	if l % 2 == 0:
		l_c = l
		l_n = l + 1
	else:
		l_c = l + 1
		l_n = l
	if r % 2 == 0:
		r_c = r
		r_n = r - 1
	else:
		r_c = r - 1
		r_n = r
	if (r_n - l_n + 1) % 2 != 0:
		m = (r_n - l_n + 1) // 2 + 1
	else:
		m = (r_n - l_n + 1) // 2
	s_1 = -1 * ((r_n + l_n) // 2 * m)
	if (r_c - l_c) % 2 == 0:
		k = (r_c - l_c) // 2 + 1
	else:
		k = (r_c - l_c + 1) // 2
	s_2 = (r_c + l_c) // 2 * k
	print(s_2 + s_1)


q = int(input())
while q > 0:
	q = q - 1
	(l, r) = map(int, input().split())
	os = ((r + 1) // 2) ** 2 - (l // 2) ** 2
	es = (r // 2) ** 2 + r // 2 - (((l - 1) // 2) ** 2 + (l - 1) // 2)
	print(es - os)


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


def f(x):
	if x % 2 == 1:
		return f(x - 1) - x
	else:
		return x // 2
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


for _ in range(int(input())):
	(l, r) = list(map(int, input().split()))
	if r == l:
		print(pow(-1, r) * r)
	elif l & 1 != 0 and r & 1 == 0:
		print((r - l + 1) // 2)
	elif l & 1 != 0 and r & 1 != 0:
		print((r - l) // 2 - r)
	elif l & 1 == 0 and r & 1 == 0:
		print(l + (r - l) // 2)
	else:
		print(-(r - l + 1) // 2)


n = int(input())
while n:
	n -= 1
	(l, r) = map(int, input().split(' '))
	t = r - l + 1
	ans = 0
	if t & 1:
		if r & 1:
			ans = -r
		else:
			ans = r
	t = t // 2
	if l & 1:
		print(ans + t)
	else:
		print(ans - t)


t = int(input())
sum = 0
for i in range(t):
	(x, y) = map(int, input().strip().split())
	if y - x == 0:
		if x % 2 == 0:
			sum = x
		else:
			sum = -x
	elif x % 2 == 1:
		if (y - x + 1) % 2 == 0:
			sum = (y - x + 1) // 2
		else:
			sum = sum = (y - x + 1) // 2 - y
	elif (y - x + 1) % 2 == 0:
		sum = -((y - x + 1) // 2)
	else:
		sum = -((y - x + 1) // 2) + y
	print(sum)


def f(r):
	if r == 0:
		return 0
	else:
		if r % 2 == 0:
			o = int(r / 2)
			e = int(r / 2)
		else:
			o = int(r / 2) + 1
			e = int(r / 2)
		return e * (e + 1) - o ** 2
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = f(b)
	y = f(a - 1)
	print(x - y)


from math import ceil
q = int(input())
while q:
	(l, r) = [int(x) for x in input().split()]
	if l == r:
		if l & 1:
			print(-l)
		else:
			print(l)
	else:
		temp = r - l + 1
		if temp % 2 == 0:
			if r % 2 == 0:
				print(temp // 2)
			else:
				print(-(temp // 2))
		elif l % 2 == 0:
			print(l + (temp - 1) // 2)
		else:
			print(-l + -(temp - 1) // 2)
	q -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	m = (y // 2) ** 2 + y // 2 - (((x - 1) // 2) ** 2 + (x - 1) // 2)
	n = ((y + 1) // 2) ** 2 - (x // 2) ** 2
	print(m - n)


for _ in range(int(input())):
	(l, r) = map(int, input().split())
	if l % 2 == 0:
		se = l
		so = l + 1
	else:
		so = l
		se = l + 1
	if r % 2 == 0:
		ee = r
		eo = r - 1
	else:
		eo = r
		ee = r - 1
	n1 = (ee - se + 2) // 2
	a = n1 * (se + ee) // 2
	n2 = (eo - so + 2) // 2
	b = n2 * (so + eo) // 2
	print(a - b)


from math import ceil
q = int(input())
for _ in range(q):
	(l, r) = map(int, input().split())
	if l == 1:
		if r % 2 == 0:
			print(int(ceil(r / 2)))
		else:
			print(-int(ceil(r / 2)))
	else:
		if r % 2 == 0:
			b = ceil(r / 2)
		else:
			b = -ceil(r / 2)
		if (l - 1) % 2 == 0:
			a = ceil((l - 1) / 2)
		else:
			a = -ceil((l - 1) / 2)
		print(int(b - a))


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


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))

def f(x):
	return x // 2 - x % 2 * x
n = I()
for i in range(n):
	(l, r) = IL()
	print(f(r) - f(l - 1))


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


x = int(input())
for i in range(x):
	(a, b) = [int(i) for i in input().split()]
	s = len(range(a, b, 2))
	if a % 2:
		if b % 2:
			s -= b
	elif b % 2:
		s = -s
	else:
		s = b - s
	print(s)


import sys

def int_reader():
	yield from (int(d) for d in sys.stdin.read().split())

def calc(x):
	res = (x + 1) // 2
	if x % 2 == 1:
		res *= -1
	return res
ints = int_reader()
q = next(ints)
for i in range(q):
	(l, r) = (next(ints), next(ints))
	print(calc(r) - calc(l - 1))


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


import math
query_count = int(input())

def get_sum(last_idx):
	if last_idx == 0:
		return 0
	else:
		positive = last_idx // 2
		added = 0
		if last_idx % 2 == 1:
			added = last_idx * math.pow(-1, last_idx)
		return positive + added
ans_arr = [0] * query_count
for j in range(query_count):
	start_end = list(map(int, input().split()))
	start = start_end[0]
	end = start_end[1]
	ans_arr[j] = get_sum(end) - get_sum(start - 1)
for ans in ans_arr:
	print(int(ans))


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())


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


import math
Q = int(input())
LR = list()
answeRs = list()
for a in range(Q):
	LR.append(input().split())
for a in range(len(LR)):
	ans = ''
	L = int(LR[a][0])
	R = int(LR[a][1])
	if L % 2 is 0 and R % 2 is 0:
		ans += str(int((L + R) / 2))
	elif L % 2 is 1 and R % 2 is 0:
		ans += str(int((R - L + 1) / 2))
	elif L % 2 is 0 and R % 2 is 1:
		ans += str(int(-1 * (R - L + 1) / 2))
	else:
		ans += str(int((R - 1 + (L + 1)) / 2 - L - R))
	print(ans)


for _ in range(int(input())):
	(l, r) = map(int, input().split())
	if r % 2 == 1:
		no = (r + 1) // 2
		ne = (r - 1) // 2
	if r % 2 == 0:
		no = r // 2
		ne = r // 2
	ae = 2
	ao = 1
	de = 2
	do = 2
	se = ne * (2 * ae + (ne - 1) * de) // 2
	so = no * (2 * ao + (no - 1) * do) // 2
	d1 = se - so
	if l % 2 == 1:
		n1o = (l + 1) // 2
		n1e = (l - 1) // 2
	if l % 2 == 0:
		n1o = l // 2
		n1e = l // 2
	ae = 2
	ao = 1
	de = 2
	do = 2
	s1e = n1e * (2 * ae + (n1e - 1) * de) // 2
	s1o = n1o * (2 * ao + (n1o - 1) * do) // 2
	d2 = s1e - s1o
	if l % 2 == 0:
		l = l
	else:
		l = -l
	d = d1 - d2 + l
	print(d)


import math
for q in range(int(input())):
	(l, r) = map(int, input().split())
	l = l - 1
	if l & 1:
		l = -math.ceil(l / 2)
	else:
		l = math.ceil(l / 2)
	if r & 1:
		r = -math.ceil(r / 2)
	else:
		r = math.ceil(r / 2)
	print(r - l)


import math

def even_sum(n):
	return n * (n + 1)

def odd_sum(n):
	return n ** 2

def answer_query(begin, end):
	ae = math.ceil(begin / 2)
	be = math.floor(end / 2)
	ao = math.ceil((begin + 1) / 2)
	bo = math.floor((end + 1) / 2)
	ans = even_sum(be) - even_sum(ae - 1)
	ans -= odd_sum(bo) - odd_sum(ao - 1)
	print(ans)
num_queries = int(input())
for _ in range(num_queries):
	(begin, end) = [int(x) for x in input().split()]
	answer_query(begin, end)


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


def mainA():
	(n, k) = map(int, input().split())
	a = (2 * n, 5 * n, 8 * n)
	print(sum(map(lambda x: (x + k - 1) // k, a)))

def mainB():

	def calc(x):
		return -x + x // 2 if x & 1 else x // 2
	T = int(input())
	for t in range(T):
		(l, r) = map(int, input().split())
		print(calc(r) - calc(l - 1))
mainB()


for _ in range(int(input().strip())):
	(l, r) = map(int, input().split())
	ne = r // 2 - (l - 1) // 2
	no = r - l + 1 - ne
	fe = l if l % 2 == 0 else l + 1
	le = r if r % 2 == 0 else r - 1
	fo = l if l % 2 else l + 1
	lo = r if r % 2 else r - 1
	se = ne * (fe + le) // 2
	so = no * (fo + lo) // 2
	print(se - so)


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	x -= 1
	cx = (x + 1) // 2 * (1 - 2 * (x % 2))
	cy = (y + 1) // 2 * (1 - 2 * (y % 2))
	print(cy - cx)


def get(n):
	return n * (n + 1) // 2 - (1 + n - (1 - n % 2)) * ((n + 1) // 2)
q = int(input())
for i in range(q):
	(l, r) = list(map(int, input().split()))
	print(get(r) - get(l - 1))


from math import ceil
for i in range(int(input())):
	(l, r) = map(int, input().split())
	if l % 2 == 0 and r % 2 != 0:
		l = ceil(l / 2)
		r = ceil(r / 2)
		x1 = -1 * r ** 2
		x2 = (r - 1) * r
		y1 = (l - 1) * l
		y2 = -1 * l ** 2
	elif l % 2 != 0 and r % 2 == 0:
		l = ceil(l / 2)
		r = ceil(r / 2)
		x1 = r * (r + 1)
		x2 = -1 * r ** 2
		y1 = -1 * (l - 1) ** 2
		y2 = (l - 1) * l
	elif l % 2 == 0 and r % 2 == 0:
		l = ceil(l / 2)
		r = ceil(r / 2)
		x1 = r * (r + 1)
		x2 = -1 * r ** 2
		y1 = (l - 1) * l
		y2 = -1 * l ** 2
	else:
		l = ceil(l / 2)
		r = ceil(r / 2)
		x1 = -1 * r ** 2
		x2 = (r - 1) * r
		y1 = -1 * (l - 1) ** 2
		y2 = l * (l - 1)
	print(x1 + x2 - y1 - y2)


import math

def get_sum(n):
	return -math.ceil(n / 2) ** 2 + math.floor(n / 2) ** 2 + math.floor(n / 2)
q = int(input())
for i in range(0, q):
	(l, r) = tuple(map(int, input().split()))
	print(get_sum(r) - get_sum(l - 1))


def solve():
	line = input()
	q = int(line.split(' ')[0])
	i = 1
	sum = []
	while i <= q:
		line = input()
		l = int(line.split(' ')[0])
		r = int(line.split(' ')[1])
		a = (r - l + 1) // 2 * pow(-1, l + 1)
		b = (r - l + 1) % 2 * r * pow(-1, r)
		sum.append(a + b)
		i += 1
	i = 1
	while i <= q:
		print(sum[i - 1])
		i += 1
solve()


q = int(input())
sm = lambda n: n * (n + 1) // 2
for _ in range(q):
	(l, r) = map(int, input().split())
	l_ = l + (l & 1)
	r_ = r - (r & 1)
	en = (r_ - l_) // 2 + 1
	n = r - l + 1
	es = (l_ - 2) * en + 2 * sm(en)
	print(2 * es - (sm(r) - sm(l - 1)))


def get(r):
	res = (r + 1) // 2
	if r % 2:
		res *= -1
	return res
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	print(get(r) - get(l - 1))


def s(x):
	return -((x + 1) // 2) if x & 1 else x // 2
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print(s(y) - s(x - 1))


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		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())
(N,) = getIntList()
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())
for _ in range(q):
	(a, b) = map(int, input().split())
	if a % 2 == 1 and b % 2 == 1:
		print(-1 * a - (b - a + 1) // 2)
	elif a % 2 == 1 and b % 2 == 0:
		print((b - a + 1) // 2)
	elif a % 2 == 0 and b % 2 == 0:
		print(a + (b - a + 1) // 2)
	else:
		print(-(b - a + 1) // 2)


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


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()

def solve(l, r):
	if l == r:
		if l % 2:
			return -l
		else:
			return l
	if l == 1:
		if r % 2:
			r = r // 2 + 1
			ans = -r ** 2
			r -= 1
			ans += r * (r + 1)
		else:
			r = r // 2
			ans = r * (r + 1)
			ans -= r ** 2
		return ans
	r1 = l - 1
	r2 = r
	if r1 % 2:
		r1 = r1 // 2 + 1
		ans1 = -r1 ** 2
		r1 -= 1
		ans1 += r1 * (r1 + 1)
	else:
		r1 = r1 // 2
		ans1 = r1 * (r1 + 1)
		ans1 -= r1 ** 2
	if r2 % 2:
		r2 = r2 // 2 + 1
		ans2 = -r2 ** 2
		r2 -= 1
		ans2 += r2 * (r2 + 1)
	else:
		r2 = r2 // 2
		ans2 = r2 * (r2 + 1)
		ans2 -= r2 ** 2
	return ans2 - ans1
for _ in range(int(input())):
	(l, r) = numIN()
	print(solve(l, r))


import math
n = int(input())
for i in range(n):
	queries = list(map(int, input().rstrip().split()))
	min = queries[0]
	max = queries[1]
	if min % 2 == 0 and max % 2 == 0:
		value = -(max - min) // 2 + max
	if min % 2 == 1 and max % 2 == 1:
		value = (max - min) // 2 - max
	if min % 2 == 1 and max % 2 == 0:
		value = (max - min + 1) // 2
	if min % 2 == 0 and max % 2 == 1:
		value = -(max - min + 1) // 2
	print(value)


n = int(input())
for i in range(n):
	(p, k) = map(int, input().split())
	r = k + 1 - p
	s = k - p
	if p % 2 == 1 and r % 2 == 1 and (s != 0):
		print(r // 2 - k)
	elif s == 0 and p % 2 == 1:
		print(-p)
	elif s == 0 and p % 2 == 0:
		print(p)
	elif p % 2 == 1 and r % 2 == 0 and (s != 0):
		print(r // 2)
	elif p % 2 == 0 and r % 2 == 0:
		print(-r // 2)
	elif p % 2 == 0 and r % 2 == 1:
		print(-(r // 2) + k)


q = int(input())
for i in range(0, q):
	(x, y) = [int(x) for x in input().split()]
	l = min(x, y)
	r = max(x, y)
	if l % 2 == 0:
		if r % 2 == 0:
			print(int(l + int((r - l) / 2)))
		else:
			print(-int((r - l + 1) / 2))
	elif r % 2 == 0:
		print(int((r - l + 1) / 2))
	else:
		print(int(-l - int((r - l) / 2)))


from math import *
t = int(input().strip())
while t > 0:
	(x, y) = map(int, input().strip().split())
	a = x * (-1) ** x
	b = y * (-1) ** y
	if a > 0 and b > 0 or (a < 0 and b < 0):
		print(a + (b - a) // 2)
	elif b > 0:
		print((y - x + 1) // 2)
	else:
		print(-(y - x + 1) // 2)
	t -= 1


q = int(input())
l = []
r = []
for i in range(q):
	(ltemp, rtemp) = map(int, input().split())
	l.append(ltemp)
	r.append(rtemp)
for j in range(q):
	if l[j] % 2 == r[j] % 2:
		result = (r[j] - l[j]) // 2 * (-1) ** r[j] + l[j] * (-1) ** l[j]
	else:
		result = (r[j] - l[j] + 1) // 2 * (-1) ** r[j]
	print(result)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	print([(a + (b - a) // 2) * [1, -1][a % 2], (b - a + 1) // 2 * [1, -1][b % 2]][not (b - a + 1) % 2])


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


from sys import stdin
all_in = stdin.readlines()
q = int(all_in[0])
l_r = list(map(lambda x: tuple(map(int, x.split())), all_in[1:]))

def sum_(a, b):
	x = max(0, a - 1 - a % 2)
	y = b - (1 - b % 2)
	s1 = b * (b + 1) // 2
	s2 = a * (a - 1) // 2
	s3 = ((y + 1) // 2) ** 2
	s4 = ((x + 1) // 2) ** 2
	return s1 - s2 - 2 * s3 + 2 * s4
print('\n'.join(map(str, list(map(lambda z: sum_(*z), l_r)))))


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


def solve():
	(l, r) = map(int, input().split())
	cnt = r - l + 1
	result = cnt // 2
	if l % 2 == 0:
		result *= -1
	if cnt % 2 == 1:
		result += r if r % 2 == 0 else -r
	print(result)
for _ in range(int(input())):
	solve()


def solve(l, m):
	l -= 1
	m1 = (m + 1) // 2
	l1 = (l + 1) // 2
	ods = m1 * m1 - l1 * l1
	t1 = m * (m + 1) // 2
	t2 = l * (l + 1) // 2
	ts = t1 - t2
	evs = ts - ods
	print(evs - ods)
t = int(input())
while t != 0:
	t -= 1
	(l, m) = input().split()
	l = int(l)
	m = int(m)
	solve(l, m)


q = int(input())

def suma(l, r):
	if l == r and r % 2 == 0:
		return r
	if l == r and r % 2 == 1:
		return -r
	if l % 2 == 1 and r % 2 == 0:
		return (r - l + 1) / 2
	if l % 2 == 0 and r % 2 == 0:
		return suma(l + 1, r) + l
	if l % 2 == 1 and r % 2 == 1:
		return suma(l, r - 1) - r
	return suma(l + 1, r - 1) + l - r
for i in range(q):
	lista = list(map(int, input().split()))
	a = lista[0]
	b = lista[1]
	print(int(suma(a, b)))


n = int(input())
while n != 0:
	str = input()
	str = str.split(' ')
	f = int(str[0])
	t = int(str[1])
	f -= 1
	if f % 2 == 0:
		f = f / 2
	else:
		f = -(f + 1) / 2
	if t % 2 == 0:
		t = t / 2
	else:
		t = -(t + 1) / 2
	print(int(t - f))
	n -= 1


n = int(input())
result = []

def calSum(n):
	if n <= 0:
		return 0
	if n % 2 == 0:
		even = n * (2 + n) // 4
		odd = -(n * n) // 4
	else:
		even = n // 2 * (2 + n - 1) // 2
		odd = -((n + 1) // 2) * (1 + n) // 2
	return even + odd
for i in range(n):
	[l, r] = [int(x) for x in input().split(' ')]
	result.append(calSum(r) - calSum(l - 1))
for r in result:
	print(r)


n = int(input())
Sum = 0
t = []
for i in range(n):
	(a, b) = map(int, input().split())
	ua = a if a % 2 == 0 else a + 1
	ub = b if b % 2 == 0 else b - 1
	Sum += (ua + ub) * ((ub - ua) // 2 + 1) // 2
	ua = a if a % 2 == 1 else a + 1
	ub = b if b % 2 == 1 else b - 1
	Sum -= (ub + ua) * ((ub - ua) // 2 + 1) // 2
	print(Sum)
	Sum = 0


q = int(input())

def f(l, r):
	ans = 0
	n = abs(r) - abs(l) + 1
	if l % 2 != 0 and l > 0:
		l = -l
	if r % 2 != 0 and r > 0:
		r = -r
	if n == 1:
		return r
	if n % 2 != 0:
		return (l + r) / 2
	elif l < 0 and r > 0:
		return l + f(-l + 1, r)
	elif l > 0 and r < 0:
		return l + f(-l - 1, r)
for i in range(q):
	(l, r) = map(int, input().split())
	print(int(f(l, r)))


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


from math import *
q = int(input())
v = [0] * q
for i in range(q):
	(l, r) = map(int, input().split())
	if l % 2 == 0 and r % 2 == 0:
		v[i] = (r + l) // 2 * ((r - l) // 2 - 1)
		v[i] -= (r + l) // 2 * ((r - l - 2) // 2 - 1)
	if l % 2 == 0 and r % 2 != 0:
		v[i] = (r + l - 1) // 2 * ((r - l + 1) // 2)
		v[i] -= (r + l + 1) // 2 * ((r - l - 1) // 2 + 1)
	if l % 2 != 0 and r % 2 != 0:
		v[i] = (r + l) // 2 * ((r - l) // 2)
		v[i] -= (r + l) // 2 * ((r - l) // 2 + 1)
	if l % 2 != 0 and r % 2 == 0:
		v[i] = (r + l + 1) // 2 * ((r - l + 1) // 2)
		v[i] -= (r + l - 1) // 2 * ((r - l + 1) // 2)
for i in range(q):
	print(v[i])


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


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))

def cal(n):
	if n % 2 == 0:
		return n // 2
	else:
		return (n - 1) // 2 - n
for _ in range(get_int()):
	(a, b) = get_int_list()
	print(cal(b) - cal(a - 1))


class CodeforcesTask1080BSolution:

	def __init__(self):
		self.result = ''
		self.q = 0
		self.queries = []

	def read_input(self):
		self.q = int(input())
		for x in range(self.q):
			self.queries.append([int(y) for y in input().split(' ')])

	def process_task(self):
		results = []
		for query in self.queries:
			if query[0] == query[1]:
				results.append(query[0] if not query[0] % 2 else -query[0])
			elif query[0] % 2 and query[1] % 2:
				results.append(-query[0] + -1 * ((query[1] - query[0]) // 2))
			elif query[0] % 2 and (not query[1] % 2):
				results.append((query[1] - query[0] + 1) // 2)
			elif not query[0] % 2 and query[1] % 2:
				results.append(-(query[1] - query[0]) // 2)
			else:
				results.append(query[0] + (query[1] - query[0]) // 2)
		self.result = '\n'.join([str(x) for x in results])

	def get_result(self):
		return self.result
Solution = CodeforcesTask1080BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	diff = x[1] - x[0] + 1
	sum1 = 0
	sum2 = 0
	even = 0
	odd = 0
	if diff % 2 == 0:
		diff = diff // 2
		even = diff
		odd = diff
		if x[0] % 2 == 0:
			sum1 += even * (2 * x[0] + (even - 1) * 2) // 2
			sum2 += odd * (2 * (x[0] + 1) + (odd - 1) * 2) // 2
		else:
			sum2 += odd * (2 * x[0] + (odd - 1) * 2) // 2
			sum1 += even * (2 * (x[0] + 1) + (even - 1) * 2) // 2
	else:
		diff = diff // 2
		if x[0] % 2 == 0:
			even = diff + 1
			odd = diff
			sum1 += even * (2 * x[0] + (even - 1) * 2) // 2
			sum2 += odd * (2 * (x[0] + 1) + (odd - 1) * 2) // 2
		else:
			even = diff
			odd = diff + 1
			sum2 += odd * (2 * x[0] + (odd - 1) * 2) // 2
			sum1 += even * (2 * (x[0] + 1) + (even - 1) * 2) // 2
	print(sum1 - sum2)


def f(n):
	return (n + 1) // 2 * (-1) ** (n % 2)
q = int(input())
for i in range(0, q):
	(a, b) = map(int, input().split())
	print(f(b) - f(a - 1))


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	if (b - a + 1) % 2:
		if a % 2:
			print(-1 * (a + (b - a) // 2))
		else:
			print(a + (b - a) // 2)
	elif b % 2:
		print(-1 * ((b - a + 1) // 2))
	else:
		print((b - a + 1) // 2)


q = int(input())
for p in range(q):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	if l % 2 == 0:
		odd = int((r - l + 1) / 2)
		even = r - l + 1 - odd
		odd_a = l + 1
		even_a = l
	else:
		even = int((r - l + 1) / 2)
		odd = r - l + 1 - even
		odd_a = l
		even_a = l + 1
	odd_sum = odd * (odd + odd_a - 1)
	even_sum = even * (even + even_a - 1)
	print(even_sum - odd_sum)


def presum(a):
	if a & 1:
		return -(a + 1) // 2
	else:
		return a // 2
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	print(presum(r) - presum(l - 1))


n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	if l == r:
		print(l * (1 if l % 2 == 0 else -1))
	else:
		fodd = l if l % 2 == 1 else l + 1
		lodd = r if r % 2 == 1 else r - 1
		feven = l if l % 2 == 0 else l + 1
		leven = r if r % 2 == 0 else r - 1
		odd = (fodd + lodd) * (1 + (lodd - fodd) // 2) // 2
		even = (feven + leven) * (1 + (leven - feven) // 2) // 2
		print(even - odd)


q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	(fn, fp, ln, lp) = (0, 0, 0, 0)
	if l % 2 == 0:
		fn = l + 1
		fp = l
	else:
		fn = l
		fp = l + 1
	if r % 2 == 0:
		ln = r - 1
		lp = r
	else:
		ln = r
		lp = r - 1
	(odd, even) = (0, 0)
	if l % 2 == 0 and r % 2 == 0:
		even = (r - l + 2) // 2
		odd = r - l + 1 - even
	elif l % 2 == 0 and r % 2 != 0:
		even = (r - l + 2) // 2
		odd = r - l + 1 - even
	elif l % 2 != 0 and r % 2 == 0:
		odd = (r - l + 2) // 2
		even = r - l + 1 - odd
	else:
		odd = (r - l + 2) // 2
		even = r - l + 1 - odd
	neg = (-fn - ln) // 2 * odd
	pos = (fp + lp) // 2 * even
	print(neg + pos)


for i in range(int(input())):
	(start, stop) = map(int, input().split())
	sign = -1 if start % 2 else 1
	if (stop - start) % 2:
		print(-sign * (stop - start + 1) // 2)
	else:
		print(sign * (start + (stop - start) // 2))


n = int(input())
for x in range(n):
	l = list(map(int, input().split()))
	if l[0] % 2 != 0:
		if (l[1] - l[0] + 1) % 2 != 0:
			ans = (l[1] - l[0]) // 2 + l[1] * -1
		else:
			ans = (l[1] - l[0] + 1) // 2
	elif (l[1] - l[0] + 1) % 2 == 0:
		ans = (l[1] - l[0] + 1) // 2 * -1
	else:
		ans = (l[1] - l[0] + 1) // 2 * -1 + l[1]
	print(ans)


q = int(input())
I = []
R = []
for i in range(0, q):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 0:
		print(int((a + b) / 2))
	if a % 2 == 1 and b % 2 == 0:
		print(int((b - a + 1) / 2))
	if a % 2 == 0 and b % 2 == 1:
		print(int(-(b - a + 1) / 2))
	if a % 2 == 1 and b % 2 == 1:
		print(int(-(a + b) / 2))


import math

def f(n):
	sign = [1, -1][n % 2]
	v = math.ceil(n / 2)
	return sign * v
q = int(input())
for _ in range(q):
	(l, r) = map(int, input().split())
	lsum = f(l - 1)
	rsum = f(r)
	print(rsum - lsum)


q = int(input())

def question(l, r):

	def a(q):
		if q % 2 == 0:
			return q
		else:
			return q * -1
	if l == r:
		return a(l)
	elif (r - l + 1) % 2 == 0:
		return (r - l + 1) // 2 * (a(r) + a(r - 1))
	else:
		return (r - l + 1) // 2 * (a(r) + a(r - 1)) + a(l)
for i in range(q):
	(a, b) = map(int, input().split())
	print(question(a, b))


from math import ceil

def ps(l):
	v = ceil(l / 2)
	v *= -1 if l % 2 == 1 else 1
	return v

def solve():
	return ps(r) - ps(l - 1)

def main():
	global l, r
	for _ in range(int(input())):
		(l, r) = list(map(int, input().split()))
		print(solve())
main()


q = int(input())
for i in range(0, q):
	(l, r) = [*map(int, input().split())]
	if l == r:
		if l % 2 == 0:
			print(l)
		else:
			print(-l)
		continue
	k1 = (r - l + 1) // 2
	if (r - l + 1) % 2 == 1:
		k1 += 1
	k2 = r - l + 1 - k1
	k1 -= 1
	k2 -= 1
	a1 = (k1 + 1) * l + k1 * (k1 + 1)
	a2 = (k2 + 1) * (l + 1) + k2 * (k2 + 1)
	if l % 2 == 0:
		print(a1 - a2)
	else:
		print(a2 - a1)


t = int(input())
for i in range(t):
	(l, r) = list(map(int, input().split(' ')))
	delta = r - l + 1
	if delta % 2:
		if r % 2:
			print(int(+(delta - 1) / 2 - r))
		else:
			print(int(-(delta - 1) / 2 + r))
	elif r % 2:
		print(int(-delta / 2))
	else:
		print(int(delta / 2))


import math
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	l = l - 1
	if l % 2 is 0:
		temp1 = int(int(l / 2) * (int(l / 2) + 1)) - int(int(l / 2) ** 2)
	else:
		temp1 = int(int(l / 2) * (int(l / 2) + 1)) - int((int(l / 2) + 1) ** 2)
	if r % 2 is 0:
		temp2 = int(int(r / 2) * (int(r / 2) + 1)) - int(int(r / 2) ** 2)
	else:
		temp2 = int(int(r / 2) * (int(r / 2) + 1)) - int((int(r / 2) + 1) ** 2)
	print(temp2 - temp1)


q = int(input())
for _ in range(q):
	(l, r) = map(int, input().split())
	le = re = 0
	if l % 2 == 0:
		le = 1
	if r % 2 == 0:
		re = 1
	ans = (r - l + 1) // 2
	if le == 0 and re == 1:
		print(ans)
	elif le == 1 and re == 0:
		print(ans * -1)
	elif le == 0 and re == 0:
		if r % 2 == 0:
			print(ans + r)
		else:
			print(ans - r)
	elif le == 1 and re == 1:
		if r % 2 == 0:
			print(-1 * ans + r)
		else:
			print(-1 * ans - r)


import math

def func(l, r):
	if l % 2 == 0:
		if r % 2 == 0:
			print(int((r + l) / 2))
		else:
			print(math.floor((l - r) / 2))
	elif r % 2 != 0:
		print(int(-1 * (r + l) / 2))
	else:
		print(math.ceil((r - l) / 2))
for t in range(int(input())):
	l = list(map(int, input().split()))
	(l, r) = (l[0], l[1])
	func(l, r)


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


N = int(input())
for i in range(N):
	X = list(map(int, input().split()))
	if X[0] == X[1]:
		print(X[0] if X[0] % 2 == 0 else -X[0])
		continue
	SUM = 0
	if X[1] % 2 == 0:
		print(int((X[1] + X[0]) / 2) if X[0] % 2 == 0 else int((X[1] + X[0] + 1) / 2) - X[0])
		continue
	print(-int((X[1] + X[0]) / 2) if X[0] % 2 != 0 else -int((X[1] + X[0] + 1) / 2) + X[0])


from sys import stdin
from math import floor, ceil

def ans(x):
	if x % 2 == 0:
		return int(x / 2)
	else:
		return -x + int((x - 1) / 2)
casos = int(stdin.readline())
for i in range(casos):
	(x, y) = map(int, stdin.readline().split())
	print(ans(y) - ans(x - 1))


import sys
q = int(sys.stdin.readline().strip())
for _ in range(q):
	(l, r) = [int(i) for i in sys.stdin.readline().strip().split()]
	if (r - l + 1) % 2 == 0:
		if l % 2 != 0:
			x = (r - l + 1) // 2
		else:
			x = -((r - l + 1) // 2)
	elif l % 2 != 0:
		x = (r - l) // 2 - r
	else:
		x = r - (r - l) // 2
	print(x)


def sum_n(n):
	if n == 0:
		return 0
	odd_c = (n + 1) // 2
	even_c = n // 2

	def sn(n):
		return n * (n + 1) // 2
	return 2 * sn(even_c) - odd_c - 2 * sn(odd_c - 1)

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


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	n = n - 1
	e1 = n // 2
	o1 = n // 2
	if n % 2 == 1:
		o1 += 1
	x1 = e1 * (e1 + 1)
	y1 = o1 * o1
	s1 = x1 - y1
	if n == 0:
		s1 = 0
	e2 = k // 2
	o2 = k // 2
	if k % 2 == 1:
		o2 += 1
	x2 = e2 * (e2 + 1)
	y2 = o2 * o2
	s2 = x2 - y2
	print(s2 - s1)


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


for _ in [0] * int(input()):
	(l, r) = map(int, input().split())
	l -= 1
	print([1, -1][r % 2] * --r // 2 - [1, -1][l % 2] * --l // 2)


n = int(input())
num = 0
odd = 0
even = 0
for i in range(n):
	(l, r) = map(int, input().split())
	odd1 = (r + 1) // 2
	even1 = r // 2
	res1 = even1 * (even1 + 1) - odd1 ** 2
	odd2 = l // 2
	even2 = (l - 1) // 2
	res2 = even2 * (even2 + 1) - odd2 ** 2
	print(res1 - res2)


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


n = int(input())
for i in range(0, n):
	a = list(map(int, input().split()))
	l = a[0]
	r = a[1]
	if l % 2 == 1:
		if (r - l) % 2 == 0:
			print(int((-l - r) / 2))
		else:
			print(int((-r - l + 1) / 2 + r))
	elif (r - l) % 2 == 0:
		print(int((l + r) / 2))
	else:
		print(int((l - r - 1) / 2))


import math
n = int(input())
while n > 0:
	(a, b) = map(int, input().split())
	if a == b and a % 2 == 0:
		print(a)
	elif a == b and a % 2 == 1:
		print(0 - a)
	elif a % 2 == 0 and b % 2 == 0:
		tot = (b - (a - 1)) * (a - 1 + b + 1) // 2
		ans = ((b - a) // 2 + 1) * (a + b) // 2
		tot = tot - ans
		print(ans - tot)
	elif a % 2 == 1 and b % 2 == 1:
		tot = (b - (a - 1)) * (a - 1 + b + 1) // 2
		ans = ((b - a) // 2 + 1) * (a + b) // 2
		print(tot - ans - ans)
	elif a % 2 == 0 and b % 2 == 1:
		ans = (b - a) // 2 + (b - a) % 2
		print(0 - ans)
	elif a % 2 == 1 and b % 2 == 0:
		ans = (b - a) // 2 + (b - a) % 2
		print(ans)
	n = n - 1


def f(start: int, end: int) -> int:
	return f2(end) - f2(start - 1)

def f2(end: int) -> int:
	end += 1
	val = end // 2
	sign = end % 2 * 2 - 1
	return val * sign
q = int(input())
for _ in range(q):
	(l, r) = map(int, input().split())
	ans = f(l, r)
	print(ans)


def getsum(n):
	if n % 2 == 0:
		odd = n // 2
		even = n // 2
	else:
		odd = n // 2 + 1
		even = n // 2
	sum = -odd * odd + even * (even + 1)
	return sum
for i in range(int(input())):
	(l, r) = map(int, input().split())
	print(getsum(r) - getsum(l - 1))


q = int(input())
for quer in range(q):
	[l, r] = [int(i) for i in input().split()]
	ans = (r - l + 1) // 2 * (-1) ** (l + 1)
	ans += (r - l + 1) % 2 * r * (-1) ** r
	print(ans)


def getSum(n):
	x = n * (n + 1)
	x //= 2
	if n % 2 == 0:
		n -= 1
	n = (n + 1) // 2
	y = n * n
	return x - y * 2
q = int(input())
while q:
	q -= 1
	(l, r) = map(int, input().split())
	if l == 1:
		print(getSum(r))
	else:
		print(getSum(r) - getSum(l - 1))


def a(i):
	if i % 2 == 0:
		return i
	return -i

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


def main():
	q = int(input())
	for _ in range(q):
		(l, r) = map(int, input().split())
		n = r - l + 1
		if n % 2 == 0:
			if ai(l) % 2 == 1:
				r = 1 * (n // 2)
			else:
				r = -1 * (n // 2)
		elif ai(l) % 2 == 1:
			r = 1 * (n // 2) + ai(r)
		else:
			r = -1 * (n // 2) + ai(r)
		print(r)

def ai(i):
	return i if i % 2 == 0 else -1 * i
main()


for i in range(int(input())):
	(m, n) = map(int, input().split())
	if m % 2 != 0 and n % 2 != 0:
		print((n - m) // 2 - n)
	elif m % 2 == 0 and n % 2 == 0:
		print((m - n) // 2 + n)
	elif m % 2 == 0:
		print((m - 1 - n) // 2)
	else:
		print((n + 1 - m) // 2)


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	v = n * (n + 1) // 2
	u = (m - 1) * m // 2
	v = v - u
	if n % 2 == 0:
		w = n - 1
	else:
		w = n
	if m % 2 == 0:
		x = m + 1
	else:
		x = m
	print(v - ((w - x) // 2 + 1) * (w + x))


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

def fo(n):
	if n == 0:
		return 0
	if n % 2 == 0:
		n -= 1
	return (n // 2 + 1) ** 2

def fe(n):
	if n == 0:
		return 0
	if n % 2:
		n -= 1
	c = n // 2
	return c * (c + 1)
for _ in range(int(input())):
	(l, r) = mi()
	print(-1 * fo(r) + fe(r) - (-1 * fo(l - 1) + fe(l - 1)))


from math import ceil

def func(x):
	if x == 0:
		return 0
	if x % 2 == 0:
		return x / 2
	return ceil(x / 2) * -1
q = int(input())
while q > 0:
	(l, r) = input().split()
	print(int(func(int(r)) - func(int(l) - 1)))
	q -= 1


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


times = int(input())
for i in range(times):
	data = [int(x) for x in input().split()]
	d = data[1] - data[0]
	if d % 2 == 0:
		if data[0] % 2 == 0:
			print(data[1] - int(d / 2))
		else:
			print(int(d / 2) - data[1])
	elif data[0] % 2 == 0:
		print(int(-(1 + d) / 2))
	else:
		print(int((1 + d) / 2))


import sys
import math
import bisect
import itertools

def query_prefix_sum_value(n):
	ans = (n + 1) * n // 2
	if n % 2 == 1:
		m = n
	else:
		m = n - 1
	ans -= (m + 1) * ((m + 1) // 2)
	return ans

def query_range_sum_value(l, r):
	ans = query_prefix_sum_value(r)
	if l > 1:
		ans -= query_prefix_sum_value(l - 1)
	return ans

def main():
	for _ in range(int(input())):
		(l, r) = map(int, input().split())
		print(query_range_sum_value(l, r))
main()


from math import *

def ans(a, b):
	n = (b - a) // 2 + 1
	return n * (a + b) // 2
N = int(input())
for i in range(N):
	(l, r) = map(int, input().split())
	last = ans(2, r // 2 * 2) - ans(1, ceil(r / 2) * 2 - 1)
	first = ans(2, (l - 1) // 2 * 2) - ans(1, ceil((l - 1) / 2) * 2 - 1)
	print(last - first)


for _ in range(int(input())):
	(l, r) = map(int, input().split())
	o = r // 2
	if r % 2 != 0:
		o += 1
	e = r - o
	x = l - 1
	y = x // 2
	if x % 2 != 0:
		y += 1
	z = x - y
	s1 = o * o - y * y
	s2 = e * (e + 1) - z * (z + 1)
	print(s2 - s1)


import math
n = input()
n = int(n)
for i in range(0, n):
	(l, r) = map(int, input().split(' '))
	if l == r:
		if l % 2 == 0:
			print(l)
		else:
			print(-1 * l)
	elif l % 2 == 0:
		if r % 2 == 0:
			v1 = (l - 1) // 2
			v2 = r // 2
			t1 = (v2 - v1) * (2 * l + 2 * (v2 - v1 - 1)) // 2
			t2 = (v2 - v1 - 1) * (2 * (l + 1) + 2 * (v2 - v1 - 2)) // 2
			print(t1 - t2)
		else:
			v1 = (l - 1) // 2
			v2 = (r - 1) // 2
			t1 = (v2 - v1) * (2 * l + 2 * (v2 - v1 - 1)) // 2
			t2 = (v2 - v1) * (2 * (l + 1) + 2 * (v2 - v1 - 1)) // 2
			print(t1 - t2)
	elif r % 2 == 0:
		v1 = l // 2
		v2 = r // 2
		t1 = (v2 - v1) * (2 * (l + 1) + 2 * (v2 - v1 - 1)) // 2
		t2 = (v2 - v1) * (2 * l + 2 * (v2 - v1 - 1)) // 2
		print(t1 - t2)
	else:
		v1 = l // 2
		v2 = r // 2
		t1 = (v2 - v1) * (2 * (l + 1) + 2 * (v2 - v1 - 1)) // 2
		t2 = (v2 - v1 + 1) * (2 * l + 2 * (v2 - v1)) // 2
		print(t1 - t2)


import math

def f(x):
	if not x & 1:
		return x // 2
	else:
		return -x + f(x - 1)
n = int(input())
for j in range(n):
	(l, r) = map(int, input().split(' '))
	print(f(r) - f(l - 1))


numQueries = int(input())
for i in range(numQueries):
	leftAndRight = input().strip().split()
	left = int(leftAndRight[0])
	right = int(leftAndRight[1])
	leftMult = 1 if left % 2 == 0 else -1
	rightMult = 1 if right % 2 == 0 else -1
	numerator = leftMult * (2 * left - 1) + rightMult * (2 * right + 1)
	ans = numerator // 4
	print(ans)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import *
(q,) = I()
while q:
	q -= 1
	(l, r) = I()
	x = ceil(r / 2)
	y = floor(l / 2)
	print(r * (r + 1) // 2 - l * (l - 1) // 2 - 2 * (x ** 2 - y ** 2))


def give_response(intervals):
	for interval in intervals:
		(l, r) = interval
		if l % 2 != 0 and r % 2 == 0:
			print(int((r + 1 - l) / 2))
		elif l % 2 != 0 and r % 2 != 0:
			print(int((r - l) / 2 - r))
		elif l % 2 == 0 and r % 2 == 0:
			print(int((r - l) / 2 + l))
		elif l % 2 == 0 and r % 2 != 0:
			print(int((r - l - 1) / 2 + l - r))
n = int(input())
intervals = []
for _ in range(n):
	interval = list([int(i) for i in input().split(' ')])
	intervals.append(interval)
give_response(intervals)


for _ in range(int(input())):
	(left, right) = map(int, input().split())
	sum_left = (left if (left - 1) % 2 == 0 else -left) // 2
	sum_right = (right + 1 if right % 2 == 0 else -(right + 1)) // 2
	print(sum_right - sum_left)


import math

def sum_n_pa(a1, an, n):
	return (a1 + an) * n // 2

def sum_n_range(l, r):
	l_odd = l_even = l
	r_odd = r_even = r
	if l % 2 == 0:
		l_odd += 1
	else:
		l_even += 1
	if r % 2 == 0:
		r_odd -= 1
	else:
		r_even -= 1
	if l_odd == l and r_even == r or (r_odd == r and l_even == l):
		return sum_n_pa(l_even, r_even, (r - l) // 2 + 1) - sum_n_pa(l_odd, r_odd, (r - l) // 2 + 1)
	elif l_odd == l and r_odd == r:
		return sum_n_pa(l_even, r_even, (r_even - l_even) // 2) - sum_n_pa(l_odd, r_odd, math.ceil((r_odd - l_odd) / 2))
	else:
		return sum_n_pa(l_even, r_even, math.ceil((r_even - l_even) / 2)) - sum_n_pa(l_odd, r_odd, (r_odd - l_odd) // 2)
t = int(input())
for i in range(t):
	(l, r) = list(map(int, input().split()))
	print(sum_n_range(l, r))


q = int(input())
for tt in range(q):
	(l, r) = map(int, input().split())
	print(r // 2 - r % 2 * r - ((l - 1) // 2 - (l - 1) % 2 * (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)


from math import ceil
for t in range(int(input().strip())):
	(l, r) = map(int, input().strip().split())
	if l == 1:
		x = ceil(r / 2) * pow(-1, r)
		print(x)
	else:
		x = ceil(r / 2) * pow(-1, r)
		y = ceil((l - 1) / 2) * pow(-1, l - 1)
		z = x - y
		print(z)


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


def main():
	n = int(input())
	for i in range(n):
		(l, r) = (int(x) for x in input().split())
		solver(l, r)

def solver(l, r):
	print(query(l, r))

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


tc = int(input())

def odd(n):
	return ((n + 1) // 2) ** 2

def even(n):
	return int(n * (n + 1))
for _ in range(tc):
	(l, r) = list(map(int, input().split()))
	l -= 1
	ret = even(r // 2) - even(l // 2) - (odd(r) - odd(l))
	print(ret)


def ans(l, r):
	n = r - l + 1
	if l == r:
		if l % 2:
			return -1 * l
		else:
			return l
	if n % 2 == 0:
		if abs(l) % 2 == 0:
			return -1 * n // 2
		else:
			return n // 2
	elif abs(l) % 2 == 0:
		ans = -1 * n // 2
		ans += r
		return ans + 1
	else:
		ans = n // 2
		ans -= r
		return ans
t = int(input())
for _ in range(t):
	n = list(map(int, input().strip().split()))
	print(ans(n[0], n[1]))


q = int(input())
while q > 0:
	(l, r) = map(int, input().split())
	evenr = int(r / 2)
	oddr = r - evenr
	sumr = evenr ** 2 + evenr - oddr ** 2
	l -= 1
	evenl = int(l / 2)
	oddl = l - evenl
	suml = evenl ** 2 + evenl - oddl ** 2
	print(sumr - suml)
	q -= 1


n = int(input())

def sum(t):
	if t % 2 == 0:
		return t // 2
	else:
		return (t - 1) // 2 - t
for i in range(n):
	(a, b) = [int(j) for j in input().split()]
	print(sum(b) - sum(a - 1))


import math
n = int(input())
for _c in range(n):
	(l, r) = [int(x) for x in input().split(' ')]
	l = l - 1
	sl = -(-l // 2) * (-1) ** l
	sr = -(-r // 2) * (-1) ** r
	print(sr - sl)


q = int(input())
while q > 0:
	(l, r) = map(int, input().split())
	l1 = l % 2
	r1 = r % 2
	if l1 == 1 and r1 == 0:
		print(int((r - l + 1) / 2))
	elif l1 == 1 and r1 == 1:
		print(int((r - l) / 2 - r))
	elif l1 == 0 and r1 == 1:
		print(int((l - r - 1) / 2))
	else:
		print(int((l - r) / 2) + r)
	q -= 1


n = int(input())
for z in range(n):
	(l, r) = map(int, input().split())
	t = r // 2
	if r % 2:
		t -= r
	l -= 1
	m = l // 2
	if l % 2:
		m -= l
	print(t - m)


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


def solve(x):
	if x % 2 == 0:
		return int(x / 2)
	else:
		return -x + solve(x - 1)
for _ in range(int(input())):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	sum = solve(r) - solve(l - 1)
	print(sum)


n = int(input())
for i in range(n):
	(n1, n2) = list(map(int, input().split()))
	if n1 == n2:
		print(n1 if n1 % 2 == 0 else -n1)
	elif n2 - n1 == 1:
		result = n1 if n1 % 2 == 0 else -n1
		result += n2 if n2 % 2 == 0 else -n2
		print(result)
	else:
		result = 0
		if n1 % 2 == 0:
			result += n1
			n1 += 1
		if n2 % 2 == 1:
			result += -n2
			n2 -= 1
		result += (n2 + 1 - n1) // 2 * 1
		print(result)


t = int(input())
for _ in range(t):
	(l, r) = list(map(int, input().split()))
	if l % 2 == 0:
		l1 = l - 1 - (l - 2) // 2
	else:
		l1 = -((l - 1) // 2)
	if r % 2 == 0:
		r1 = -(r // 2)
	else:
		r1 = r - (r - 1) // 2
	print(-(r1 - l1))


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial

def get(l, r):
	if l > r:
		return 0
	if l & 1:
		return (-l - r) * (r - l + 2) // 4
	else:
		return (l + r) * (r - l + 2) // 4

def solution(l, r):
	(l1, l2, r1, r2) = (l, l, r, r)
	if l & 1:
		l2 += 1
	else:
		l1 += 1
	if r & 1:
		r2 -= 1
	else:
		r1 -= 1
	return get(l1, r1) + get(l2, r2)
q = int(stdin.readline())
for i in range(q):
	(l, r) = map(int, stdin.readline().split())
	stdout.write(str(solution(l, r)) + '\n')


import math
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	if l == r:
		if l % 2 == 0:
			print(l)
		else:
			print(-l)
		continue
	elif r == l + 1:
		if l % 2 == 0:
			print(l - r)
		else:
			print(-l + r)
		continue
	L = r - l + 1
	if L % 2 == 0:
		odd_num = int(math.floor(L / 2))
		even_num = int(math.ceil(L / 2))
	elif l % 2 == 1:
		odd_num = int(math.ceil(L / 2))
		even_num = int(math.floor(L / 2))
	else:
		odd_num = int(math.floor(L / 2))
		even_num = int(math.ceil(L / 2))
	last_odd = r if r % 2 == 1 else r - 1
	last_ev = r // 2 if r % 2 == 0 else (r - 1) // 2
	sum_odd = (last_odd // 2 + 1) ** 2 - (last_odd // 2 + 1 - odd_num) ** 2
	sum_even = (last_ev * (last_ev + 1) // 2 - (last_ev - even_num) * (last_ev - even_num + 1) // 2) * 2
	print(sum_even - sum_odd)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = b * (b + 1) // 2
	x = b - b // 2
	v = a - a // 2
	summ = x * x - v * v
	even = a
	if a & 1:
		summ += a
		even = a + 1
	n = b // 2 - a // 2
	if a % 2 == 0:
		n += 1
	s = n * (even + (n - 1))
	print(s - summ)


import math as m
t = int(input())
for _ in range(t):
	(l, r) = map(int, input().split())
	if l % 2 == 1:
		if r % 2 == 1:
			k = r
		else:
			k = 0
		ans = m.ceil((r - l) / 2) - k
	else:
		if r % 2 == 0:
			k = r
		else:
			k = 0
		ans = -m.ceil((r - l) / 2) + k
	print(ans)


def calcul(n):
	if n == 0:
		return 0
	if n % 2 == 0:
		return n / 2
	else:
		return -(n + 1) / 2
n = int(input())
l1 = [''] * n
l2 = [''] * n
for i in range(n):
	(l1[i], l2[i]) = map(int, input().split(' '))
for i in range(n):
	print(int(calcul(l2[i]) - calcul(l1[i] - 1)))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	(s, e) = (l[0], l[1])
	if s == e:
		if s % 2 == 0:
			print(s)
		else:
			print(-e)
	elif s + 1 == e:
		if s % 2 == 0:
			print(-1)
		else:
			print(1)
	elif (e - s + 1) % 2 == 0:
		if s % 2 == 0:
			print(-((e - s + 1) // 2))
		else:
			print((e - s + 1) // 2)
	elif s % 2 == 0:
		print(-((e - s) // 2) + e)
	else:
		print((e - s) // 2 - e)


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


a = int(input())
k = 0
for i in range(a):
	(a1, b1) = map(int, input().split())
	if a1 == b1:
		if a1 % 2 != 0:
			print(-a1)
		else:
			print(a1)
	elif b1 % 2 == 0:
		if a1 % 2 == 0:
			k = a1
			k -= (a1 - b1) // 2
			print(k)
		else:
			k = (b1 - a1 + 1) // 2
			print(k)
	elif b1 % 2 != 0:
		if a1 % 2 != 0:
			k = -a1
			k -= (b1 - a1) // 2
			print(k)
		else:
			print(-(b1 - a1 + 1) // 2)
	k = 0


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)


test_cases = int(input())
for each_test_case in range(test_cases):
	(l, r) = map(int, input().split())
	n = r - l + 1
	all_sum = (l + r) * n // 2
	count_odds = 0
	count_even = 0
	if l != r:
		if l % 2 != 0:
			odd_l = l
			count_odds += 1
		else:
			odd_l = l + 1
			count_even += 1
		if r % 2 != 0:
			odd_r = r
			count_odds += 1
		else:
			odd_r = r - 1
			count_even += 1
		pluser = 0
		if count_odds % 2 == 0 and count_odds > 1:
			pluser = 1
		n = n // 2
		odds_sum = (odd_l + odd_r) * (n + pluser) // 2
		odds_sum = odds_sum * -2
		print(all_sum + odds_sum)
	elif l % 2 != 0:
		print(-1 * l)
	else:
		print(l)


from math import ceil as c
for x in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		if a % 2 == 0:
			print(a)
		else:
			print(-a)
	elif a % 2 != 0 and b % 2 != 0:
		print((b - a) // 2 - b)
	elif a % 2 == 0 and b % 2 == 0:
		print(-((b - a) // 2) + b)
	elif a % 2 == 0 and b % 2 != 0:
		print(-c((b - a) / 2))
	elif a % 2 != 0 and b % 2 == 0:
		print(c((b - a) / 2))


q = int(input())
while q > 0:
	(l, r) = map(int, input().split())
	dif = r - l
	dif = dif + 1
	if dif % 2 == 0:
		if l % 2 == 0:
			print(-1 * dif // 2)
		else:
			print(dif // 2)
	else:
		dif = dif - 1
		if l % 2 == 0:
			dif = -1 * dif // 2
		else:
			dif = dif // 2
		if r % 2 == 0:
			dif = dif + r
		else:
			dif = dif + -1 * r
		print(dif)
	q -= 1


def main():
	t = int(input())
	while t:
		t -= 1
		(l, r) = map(int, input().split(' '))
		n = r // 2
		max_even = n * (n + 1)
		n = (l - 1) // 2
		min_even = n * (n + 1)
		max_odd = (r + 1) // 2 * ((r + 1) // 2)
		min_odd = l // 2 * (l // 2)
		ans = max_even - min_even - (max_odd - min_odd)
		print(ans)
main()


nRequests = int(input())
for i in range(nRequests):
	(minElemReq, maxElemReq) = map(int, input().split())
	if minElemReq % 2 == 0:
		sum = (minElemReq + maxElemReq) // 2 * ((maxElemReq - minElemReq) // 2 + 1)
		sum -= (minElemReq + maxElemReq + 1) // 2 * ((maxElemReq - minElemReq - 1) // 2 + 1)
	elif minElemReq % 2 != 0:
		sum = (minElemReq + maxElemReq + 1) // 2 * ((maxElemReq - minElemReq - 1) // 2 + 1)
		sum -= (minElemReq + maxElemReq) // 2 * ((maxElemReq - minElemReq) // 2 + 1)
	print(sum)


import math
n = int(input())
for i in range(n):
	(l, r) = map(int, input().strip().split())
	x = math.ceil((l - 1) / 2)
	y = (l - 1) // 2
	s1 = pow(x, 2)
	s2 = y * (y + 1)
	x = math.ceil(r / 2)
	y = r // 2
	s11 = pow(x, 2)
	s22 = y * (y + 1)
	a = s2 - s1
	b = s22 - s11
	print(b - a)


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


t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	x -= 1
	if x & 1:
		x = (x - 1) // 2 - x
	else:
		x //= 2
	if y & 1:
		y = (y - 1) // 2 - y
	else:
		y //= 2
	print(y - x)


q = int(input())

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


def getX(x):
	if x % 2 == 0:
		return x / 2
	return (x - 1) / 2 - x
q = int(input())
for i in range(q):
	(n, k) = [int(x) for x in input().split()]
	print(int(getX(k) - getX(n - 1)))


n = int(input())

def func(x):
	if x % 2 == 0:
		return x // 2
	elif x % 2 != 0:
		return func(x - 1) - x
for i in range(n):
	(l, r) = map(int, input().split())
	print(func(r) - func(l - 1))


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


import math

def solve(n, lis):
	for x in range(n):
		l = lis[x * 2] - 1
		r = lis[x * 2 + 1]
		sl = (-1 if l & 1 else 1) * ((l + 1) // 2)
		sr = (-1 if r & 1 else 1) * ((r + 1) // 2)
		print(sr - sl)
from sys import stdin

def intRead():
	while True:
		ln = stdin.readline().strip()
		if not ln:
			return
		for i in map(int, ln.split()):
			yield i
ipt = intRead()
n = next(ipt)
lis = [i for i in ipt]
solve(n, lis)


n = input()
(a, b) = (0, 0)
for i in range(int(n)):
	(a, b) = (int(x) for x in input().split())
	a -= 1
	print(b // 2 - b % 2 * b - a // 2 + a % 2 * a)


import math
t = int(input())

def get_sum(n):
	if n < 0:
		return 0
	_n = math.ceil(n / 2)
	if n % 2 == 0:
		return _n
	else:
		return -_n
for i in range(t):
	(n, l) = map(int, input().split())
	print(get_sum(l) - get_sum(n - 1))


def sfa(upto):
	nom = (upto + 1) // 2
	sign = 1 if upto % 2 == 0 else -1
	return nom * sign
q = int(input())
for i in range(q):
	(l, r) = [int(x) for x in input().split()]
	s = sfa(r) - sfa(l - 1)
	print(s)


T = int(input())
for _ in range(T):
	(l, r) = map(int, input().split())
	(dupl, dupr) = (l, r)
	if l == r:
		if l % 2:
			print(-1 * l)
		else:
			print(l)
	else:
		l -= 1
		xl = (l + 1) // 2
		xr = (r + 1) // 2
		vall = xl
		valr = xr
		p = 0
		if l % 2:
			vall = -1 * xl
		if r % 2:
			valr = -1 * xr
		p = valr - vall
		print(p)


for i in range(int(input())):
	(l, t) = map(int, input().split())
	y = t - l + 1
	x = y // 2
	if y & 1:
		x -= t
	if l % 2 == 0:
		x = -x
	print(x)


import sys
number = int(sys.stdin.readline())
answers = []
for _ in range(number):
	(start, finish) = map(int, sys.stdin.readline().split())
	if start == finish:
		if start % 2 != 0:
			answers.append(-start)
		else:
			answers.append(start)
	elif start % 2 != 0:
		if finish % 2 != 0:
			answers.append(-finish - start + (finish + start) // 2)
		else:
			answers.append((finish - start - 1) // 2 * -1 + finish - start)
	elif finish % 2 != 0:
		answers.append((finish - start - 1) // 2 - finish + start)
	else:
		answers.append(finish + start - (finish + start) // 2)
print(*answers, sep='\n')


for i in range(int(input())):
	(begin, end) = [int(x) for x in input().split()]
	begin -= 1
	sum_begin = 0
	sum_end = 0
	if begin % 2 == 0:
		sum_begin = begin // 2
	else:
		sum_begin = (begin + 1) // 2 * -1
	if end % 2 == 0:
		sum_end = end // 2
	else:
		sum_end = (end + 1) // 2 * -1
	print(sum_end - sum_begin)


for _ in range(int(input())):
	(X1, X2) = map(int, input().split())
	d = X2 - X1
	if X1 % 2 != 0 and X2 % 2 != 0:
		print(-X2 + d // 2 * 1)
	elif X1 % 2 != 0 and X2 % 2 == 0:
		print((d + 1) // 2)
	elif X1 % 2 == 0 and X2 % 2 != 0:
		print(-(d + 1) // 2)
	else:
		print(X2 - d // 2 * 1)


for i in range(int(input())):
	(l, r) = map(int, input().split())
	od = (r + 1) // 2
	odd = l // 2
	minus = od ** 2 - odd ** 2
	eve = r // 2
	even = (l - 1) // 2
	plus = eve * (eve + 1) - even * (even + 1)
	print(plus - minus)


from operator import itemgetter
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	ans = 0
	num = r - l + 1
	if l % 2 == 0:
		ans = -(num // 2)
		ans += r * (num % 2)
	else:
		ans = num // 2
		ans -= r * (num % 2)
	print(ans)


q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	n = r - l + 1
	if l % 2 == 0 and r % 2 == 0:
		ne = (r - l) // 2 + 1
		no = n - ne
		sum1 = ne * (l + r) // 2 - no * (l + r) // 2
	elif l % 2 == 0 and r % 2 != 0:
		ne = (r - 1 - l) // 2 + 1
		no = n - ne
		sum1 = ne * (l + r - 1) // 2 - no * (l + 1 + r) // 2
	elif l % 2 != 0 and r % 2 == 0:
		ne = (r - (l + 1)) // 2 + 1
		no = n - ne
		sum1 = ne * (l + 1 + r) // 2 - no * (l + r - 1) // 2
	else:
		ne = (r - 1 - (l + 1)) // 2 + 1
		no = n - ne
		sum1 = ne * (l + r) // 2 - no * (l + r) // 2
	print(sum1)


count = int(input())
queries = []
for i in range(count):
	line = input().split()
	(l, r) = (int(line[0]), int(line[1]))
	queries.append((l, r))

def query(l, r):
	if l == r and l % 2 == 0:
		return l
	elif l == r:
		return -l
	if l % 2 == 0:
		if r % 2 == 1:
			return -1 * ((r + 1 - l) // 2)
		else:
			return -1 * ((r + 1 - l) // 2) + r
	elif r % 2 == 0:
		return (r + 1 - l) // 2
	else:
		return (r + 1 - l) // 2 - r
for (l, r) in queries:
	print(query(l, r))


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


def principal():
	cantidad = int(input())
	arr = []
	for i in range(cantidad):
		(a, b) = map(int, input().split())
		if (b - a) % 2 == 0:
			b2 = b + 1
			if a % 2 == 0:
				c = (b2 - a + 1) / 2 * -1
				c = c + b2
			else:
				c = (b2 - a + 1) / 2
				c = c - b2
			arr.append(c)
		else:
			if a % 2 == 0:
				c = (b - a + 1) / 2 * -1
			else:
				c = (b - a + 1) / 2
			arr.append(c)
	for j in arr:
		print(int(j))
principal()


q = int(input())
l = []
for i in range(q):
	l.append([int(k) for k in input().split()])
for (m, n) in l:
	s = 0
	if m % 2 == 0:
		s += m
		m += 1
	if n % 2 == 1:
		s -= n
		n -= 1
	s += (n - m + 1) // 2
	print(s)


def sums(l, r):
	if l % 2 == 0 and r % 2 == 0:
		n = (r - l) // 2 + 1
		sum1 = n * (2 * l + (n - 1) * 2) // 2
		l += 1
		r -= 1
		n = (r - l) // 2 + 1
		sum2 = n * (2 * l + (n - 1) * 2) // 2
		return (sum1, sum2)
t = int(input())
for x in range(t):
	(l, r) = list(map(int, input().split()))
	if r - l < 10:
		sumi = 0
		for i in range(l, r + 1):
			if i % 2 == 0:
				sumi += i
			else:
				sumi -= i
		print(sumi)
		continue
	sum1 = 0
	sum2 = 0
	if l % 2 == 0 and r % 2 == 0:
		(sum1, sum2) = sums(l, r)
		print(sum1 - sum2)
	elif l % 2 == 0 and r % 2 == 1:
		sum22 = r
		r -= 1
		(sum1, sum2) = sums(l, r)
		print(sum1 - sum2 - sum22)
	elif l % 2 == 1 and r % 2 == 1:
		sum22 = r + l
		l += 1
		r -= 1
		(sum1, sum2) = sums(l, r)
		print(sum1 - sum2 - sum22)
	elif l % 2 == 1 and r % 2 == 0:
		sum22 = l
		l += 1
		(sum1, sum2) = sums(l, r)
		print(sum1 - sum2 - sum22)


q = int(input())
b = [0] * q
for i in range(q):
	a = input().split()
	l = int(a[0])
	r = int(a[1])
	n = r - l + 1
	if l % 2 == 0 and r % 2 == 1:
		b[i] = -(n // 2)
	if l % 2 == 1 and r % 2 == 0:
		b[i] = n // 2
	if l % 2 == 0 and r % 2 == 0:
		b[i] = (n - 1) // 2 + l
	if l % 2 == 1 and r % 2 == 1:
		b[i] = -((n - 1) // 2 + l)
for i in range(q):
	print(b[i])


import math
I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
t = I()
for _ in range(t):
	(l, r) = ID()
	n = r - l + 1
	m = n // 2
	if n & 1:
		m -= r
	if l % 2 == 0:
		m = -m
	print(m)


from math import ceil
n = int(input())
for i in range(n):
	(l, r) = input().split()
	su = 0
	l = int(l)
	r = int(r)
	if l == r:
		if l % 2 == 1:
			print(-l)
		else:
			print(l)
	elif l % 2 == 0 and r % 2 == 0:
		print(l + r - (r - 1) + (r - l - 1) // 2)
	elif l % 2 == 1 and r % 2 == 1:
		print(r - 1 - l - r + ceil((l - r + 1) / 2))
	elif l % 2 == 1 and r % 2 == 0:
		print(r - l + ceil((l - r + 1) / 2))
	elif l % 2 == 0 and r % 2 == 1:
		print(l - r + (r - l - 1) // 2)


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


q = int(input())
for i in range(q):
	tmp = input().split()
	l = int(tmp[0])
	r = int(tmp[1])
	sum = int(r / 2)
	if r % 2:
		sum += 1
		sum = 0 - sum
	if l == 1:
		print(sum)
	else:
		l -= 1
		r = int(l / 2)
		if l % 2:
			r += 1
			r = 0 - r
		sum -= r
		print(sum)


import math
import collections
import bisect
import heapq
import time
import itertools
import sys
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)))


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


import math
t = int(input())
while t:
	(a, b) = map(int, input().split())
	s = 0
	if a == b:
		if a % 2 == 0:
			s = a
		else:
			s = -a
	elif (b - a) % 2 == 0 and a % 2 != 0:
		s = (b - a) // 2 - b
	elif (b - a) % 2 != 0 and a % 2 != 0:
		s = (b - a) // 2 + 1
	elif (b - a) % 2 == 0 and a % 2 == 0:
		s = -1 * ((b - a) // 2) + b
	else:
		s = -1 * ((b - a) // 2 + 1)
	print(s)
	t = t - 1


def sum_odd(n):
	terms = (n + 1) // 2
	sum1 = terms * terms
	return sum1

def odd_sum_in_range(left, right):
	return sum_odd(right) - sum_odd(left - 1)

def sum_even(n):
	return n // 2 * (n // 2 + 1)

def even_sum_in_range(l, r):
	return sum_even(r) - sum_even(l - 1)
q = int(input())
inp = [[int(x) for x in input().split()] for i in range(q)]
for i in range(q):
	print(even_sum_in_range(inp[i][0], inp[i][1]) - odd_sum_in_range(inp[i][0], inp[i][1]))


n = int(input())
queries = []
for i in range(n):
	queries.append(list(map(int, input().split())))
for i in range(len(queries)):
	a = queries[i][0]
	b = queries[i][-1]
	if a % 2 != 0:
		if b % 2 != 0:
			print(int((b - a) / 2 - b))
		else:
			print(int((b - a) // 2 + 1))
	if a % 2 == 0:
		if b % 2 != 0:
			print(-int((b - a) // 2 + 1))
		else:
			print(int((a - b) / 2 + b))


import math
t = int(input())
for x in range(t):
	(start, end) = [int(i) for i in input().split()]
	if start % 2 == 0 and start + 1 == end:
		print(-1)
	elif start % 2 == 1 and start + 1 == end:
		print(1)
	elif start % 2 == 0 and end % 2 == 0:
		print(int((end - start) / 2 * -1 + end))
	elif start % 2 == 1 and end % 2 == 1:
		print(int((end - start) / 2 * 1 - end))
	elif start % 2 == 0 and end % 2 == 1:
		ans = math.ceil((end - start) / 2) * -1
		print(ans)
	elif start % 2 == 1 and end % 2 == 0:
		ans = math.ceil((end - start) / 2)
		print(ans)


def d():
	q = int(input())
	res = ''
	for i in range(q):
		suml = 0
		sumr = 0
		arrlen = list(map(int, input().split()))
		l = arrlen[0]
		r = arrlen[1]
		if l % 2 is 0 and r % 2 is 0:
			res += str(int((l + r) / 2)) + '\n'
		elif l % 2 is 1 and r % 2 is 0:
			res += str(int((r - l + 1) / 2)) + '\n'
		elif l % 2 is 0 and r % 2 is 1:
			res += str(int(-1 * (r - l + 1) / 2)) + '\n'
		else:
			res += str(int((r - 1 + (l + 1)) / 2 - l - r)) + '\n'
	print(res[:-1])
d()


n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	if r & 1:
		r1 = -((r + 1) // 2)
	else:
		r1 = r // 2
	if l - 1 & 1:
		l1 = -((l - 1 + 1) // 2)
	else:
		l1 = (l - 1) // 2
	print(r1 - l1)


import sys
import random
from itertools import permutations, combinations
from math import sqrt, fabs, ceil
from collections import namedtuple
in_file_path = 'input.txt'
output_file_path = 'output.txt'
SUBMIT = True

def read_num(fin, num_type=int):
	tmp_list = [num_type(x) for x in fin.readline().strip().split()]
	num_count = len(tmp_list)
	if num_count == 1:
		return tmp_list[0]
	elif num_count == 2:
		return (tmp_list[0], tmp_list[1])
	elif num_count == 3:
		return (tmp_list[0], tmp_list[1], tmp_list[2])
	elif num_count == 4:
		return (tmp_list[0], tmp_list[1], tmp_list[2], tmp_list[3])
	print("Can't solve :", tmp_list)
	assert False

def solve(fin):
	n = read_num(fin)
	for _ in range(0, n):
		(l, r) = read_num(fin)
		if (r - l + 1) % 2 == 0:
			if l % 2 == 0:
				print(int(-(r - l + 1) / 2))
			else:
				print(int((r - l + 1) / 2))
		elif l % 2 == 0:
			print(int(-(r - l) / 2 + r))
		else:
			print(int((r - l) / 2 - r))
if SUBMIT:
	solve(sys.stdin)
else:
	solve(open(in_file_path, 'r'))


f = lambda x: -x // 2 if x % 2 else x // 2
for _ in range(int(input())):
	(L, R) = map(int, input().split())
	print(f(R) - f(L - 1))


(q, m) = (int(input()), [])
for i in range(q):
	s = input().split()
	(a, b) = (int(s[0]), int(s[1]))
	(a, b) = (a * (-1) ** a, b * (-1) ** b)
	m += [(b + a) / 2 if (a + b) % 2 == 0 else ((abs(b) - 1) * (-1) ** (abs(b) - 1) + a) / 2 + b]
for i in m:
	print(int(i))


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


def upto(n):
	return (n + 1) // 2 * (-1 if n % 2 == 1 else 1)
q = int(input())
for query in range(q):
	(l, r) = map(int, input().split())
	print(upto(r) - upto(l - 1))


def prog():
	n = int(input())
	from sys import stdin
	for i in range(n):
		(l, r) = map(int, stdin.readline().split())
		x = r - l + 1
		y = x // 2
		(a, b) = (l % 2, r % 2)
		if a == 1:
			if b == 1:
				print(y - r)
			else:
				print(y)
		elif b == 1:
			print(-y)
		else:
			print(r - y)
prog()


amount = int(input())
for i in range(amount):
	(left, right) = [int(s) for s in input().split()]
	if left % 2 == 0 and right % 2 == 0:
		print(int((left - right) / 2 + right))
	elif left % 2 and right % 2 == 0:
		print(int((right - left + 1) / 2))
	elif left % 2 == 0 and right % 2:
		print(int((left - right - 1) / 2))
	else:
		print(int(-left + (left - right) / 2))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	(l, r) = sep()
	d = r - l + 1
	if l % 2 == 1:
		k = d // 2
		if d % 2 == 1:
			print(k + (-1) ** r * r)
		else:
			print(k)
	else:
		k = -(d // 2)
		if d % 2 == 1:
			print(k + (-1) ** r * r)
		else:
			print(k)
testcase(int(inp()))


import math
n = int(input())
for i in range(0, n):
	o = input().rstrip().split(' ')
	l = int(o[0])
	r = int(o[1])
	l = l - 1
	odd1 = int(math.ceil(l / 2))
	even1 = int(math.floor(l / 2))
	odd2 = int(math.ceil(r / 2))
	even2 = int(math.floor(r / 2))
	ans1 = even1 * (even1 + 1) - odd1 ** 2
	ans2 = even2 * (even2 + 1) - odd2 ** 2
	print(ans2 - ans1)


from math import ceil

def f(n):
	return n * (n + 1) // 2 - 2 * ceil(n / 2) ** 2
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(f(r) - f(l - 1))


def f(n):
	if n % 2 == 1:
		return -n
	else:
		return n
numLines = int(input())
nums = []
for n in range(numLines):
	(beg, last) = input().split(' ')
	nums.append([int(beg), int(last)])
for num in nums:
	if num[0] % 2 == 0 and num[1] % 2 == 0:
		suma = (num[0] + num[1]) / 2
	elif num[0] % 2 == 1 and num[1] % 2 == 0:
		suma = (num[1] - num[0] + 1) / 2
	elif num[0] % 2 == 0 and num[1] % 2 == 1:
		suma = -1 * (num[1] - num[0] + 1) / 2
	else:
		suma = (num[1] - 1 + (num[0] + 1)) / 2 - num[0] - num[1]
	print(int(suma))


def res(l, r):
	ans = 0
	if l % 2 == 0:
		l = l - 1
		ans = ans + l
	if r % 2 == 1:
		r = r + 1
		ans = ans - r
	ans = ans + (r - l + 1) // 2
	return ans
from sys import stdin
q = int(stdin.readline().split()[0])
for x in range(0, q):
	(l, r) = [int(x) for x in stdin.readline().split()]
	print(res(l, r))


n = int(input())

def f(x):
	if x % 2 == 0:
		return x / 2
	else:
		return (-x - 1) / 2
s = 0
for i in range(n):
	inp = input().split()
	start = int(inp[0])
	end = int(inp[1])
	s = f(end) - f(start - 1)
	print(int(s))


q = int(input())
for query in range(q):
	(l, r) = [int(x) for x in input().split(' ')]
	if (r - l) % 2 == 1:
		ans = (-1) ** r * ((r - l + 1) // 2)
	else:
		ans = (-1) ** (r - 1) * ((r - l) // 2) + (-1) ** r * r
	print(ans)


import math

def main():
	q = int(input())
	for i in range(q):
		(l, r) = (int(x) for x in input().split(' '))
		if l == r:
			if l % 2 == 0:
				print(l)
			else:
				print(-1 * l)
		elif l % 2 == 0:
			ind = r - l + 1
			if r % 2 == 0:
				print(-1 * (ind // 2) + r)
			else:
				print(ind // 2 * -1)
		else:
			ind = r - l + 1
			if r % 2 == 0:
				print(ind // 2)
			else:
				print(ind // 2 + -1 * r)
main()


q = int(input())
answers = []
for i in range(q):
	(l, r) = map(int, input().split())
	cou = r - l + 1
	if cou % 2 == 1:
		mid = (l + r) // 2
		answers.append(mid if r % 2 == 0 else -mid)
	else:
		answers.append(cou // 2 if r % 2 == 0 else -cou // 2)
print(*answers, sep='\n')


import sys
r = lambda : sys.stdin.readline()
fir = int(input())
for i in range(fir):
	(n, m) = map(int, r().split())
	if n == m:
		if n % 2 == 0:
			print(n)
		else:
			print(-n)
	elif n % 2 != 0 and m % 2 != 0:
		print(-int((m + n) / 2))
	elif n % 2 == 0 and m % 2 == 0:
		print(int((m + n) / 2))
	elif n % 2 != 0 and m % 2 == 0:
		print(int((m + 1 - n) / 2))
	else:
		print(-int((m + 1 - n) / 2))


from math import floor
q = int(input())

def f(l, r):
	print(l, r, floor((l + r) / 2 * (abs(r - l) // 2 + 1)))
	return floor((l + r) / 2 * (abs(r - l) // 2 + 1))
while q > 0:
	(l, r) = map(int, input().split())
	ans = 0
	if l % 2 == 0:
		t1 = (r - l + 1) // 2
		t2 = (r - l) // 2 + 1
		ans += (2 * -(l + 1) - 2 * (t1 - 1)) * t1 // 2
		ans += (2 * l + 2 * (t2 - 1)) * t2 // 2
	else:
		t1 = (r - l) // 2 + 1
		t2 = (r - l + 1) // 2
		ans += (2 * -l - 2 * (t1 - 1)) * t1 // 2
		ans += (2 * (l + 1) + 2 * (t2 - 1)) * t2 // 2
	print(int(ans))
	q -= 1


q = int(input())
for item in range(q):
	(l, r) = [int(x) for x in input().split()]
	if l % 2 == 0:
		if (r - l + 1) % 2 == 0:
			print((r - l + 1) // 2 * -1)
		else:
			print((r - l) // 2 + l)
	elif (r - l + 1) % 2 == 0:
		print((r - l + 1) // 2)
	else:
		print((r - l) // 2 * -1 + -l)


q = int(input())
for _ in range(q):
	ll = rr = 1
	(l, r) = map(int, input().split())
	if l % 2 == 1:
		ll = 0
	if r % 2 == 1:
		rr = 0
	if ll == 0 and rr == 1:
		print((r - l + 1) // 2)
	elif ll == 0 and rr == 0:
		print((r - l) // 2 - r)
	elif ll == 1 and rr == 0:
		print((r - l - 1) // 2 + l - r)
	else:
		print((r - l) // 2 + l)


n = int(input())
for i in range(n):
	(l, r) = map(int, input().split())
	dist = r - l + 1
	f = l * (-1) ** l
	s = r * (-1) ** r
	each = 1 if f < 0 else -1
	print(each * (dist // 2) + dist % 2 * s if dist > 1 else f)


def my_fun(number):
	if number % 2 == 0:
		return number // 2
	return -number + my_fun(number - 1)

def result(lst):
	a = list()
	for elem in lst:
		a.append(my_fun(elem[1]) - my_fun(elem[0] - 1))
	return a
q = int(input())
b = list()
for i in range(q):
	(s, t) = [int(i) for i in input().split()]
	b.append([s, t])
print(*result(b), sep='\n')


from math import *

def s(a, d, n):
	return (2 * a + (n - 1) * d) * n // 2
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	if l == r:
		print(-l if l % 2 else l)
	elif l % 2:
		print(s(l + 1, 2, r // 2 - (l - 1) // 2) - s(l, 2, ceil(r / 2) - ceil((l - 1) / 2)))
	else:
		print(s(l, 2, r // 2 - (l - 1) // 2) - s(l + 1, 2, ceil(r / 2) - ceil((l - 1) / 2)))


t = int(input())
for i in range(t):
	u = list(map(int, input().strip().split()))
	n = u[0]
	k = u[1]
	so = 0
	se = 0
	so1 = 0
	so2 = 0
	sum1 = 0
	if k % 2 == 0:
		h = k // 2
		so1 = h * h
	else:
		h = k // 2
		h = h + 1
		so1 = h * h
	if n % 2 == 0:
		h = n // 2
		so2 = h * h
	else:
		h = n // 2
		so2 = h * h
	so = so1 - so2
	if k % 2 == 0:
		h = k // 2
		se1 = h * (h + 1)
	else:
		h = k // 2
		se1 = h * (h + 1)
	if n % 2 == 0:
		h = (n - 1) // 2
		se2 = h * (h + 1)
	else:
		h = (n - 1) // 2
		se2 = h * (h + 1)
	se = se1 - se2
	sum1 = se - so
	print(sum1)


x = int(input())
for _ in range(x):
	total = 0
	(c, v) = [*map(int, input().split())]
	if c % 2 == 0 and v % 2 == 0:
		print((c + v) // 2)
	elif c % 2 != 0 and v % 2 != 0:
		print(-1 * (c + v) // 2)
	elif c % 2 == 0 and v % 2 != 0:
		print((c + (v - 1)) // 2 - v)
	elif c % 2 != 0 and v % 2 == 0:
		print(((c + (v - 1)) // 2 - v) * -1)


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


q = int(input())
res = []
for i in range(q):
	sum = 0
	(l, r) = map(int, input().split())
	n = r - l + 1
	if l == r:
		if l % 2 == 0:
			res.append(int(l))
		else:
			res.append(int(l * -1))
	elif l % 2 == 0 and r % 2 == 0:
		res.append(int((r - l) / 2 + l))
	elif l % 2 != 0 and r % 2 != 0:
		res.append(int(((r - l) / 2 + l) * -1))
	elif l % 2 != 0 and r % 2 == 0:
		res.append(int((r - l) / 2 + 1))
	else:
		r = (r - l) / 2 + 1
		res.append(int(r * -1))
for values in res:
	print(values)


import math
n = int(input())
for i in range(n):
	(f, s) = map(int, input().split())
	if f % 2 != 0:
		f = -f
	if s % 2 != 0:
		s = -s
	sum = (f + s) / 2
	if sum > 0:
		print(math.ceil(sum))
	elif sum < 0:
		print(math.floor(sum))
	else:
		print(sum)


def sumNatural(n):
	sum = n * (n + 1)
	return int(sum)

def sum_even(l, r):
	return sumNatural(int(r / 2)) - sumNatural(int((l - 1) / 2))

def sumOdd(n):
	terms = (n + 1) // 2
	sum1 = terms * terms
	return sum1

def sum_odd(l, r):
	return sumOdd(r) - sumOdd(l - 1)
q = int(input())
entrada = []
for i in range(q):
	entrada.append(input())
for i in range(q):
	(l, r) = entrada[i].split(' ')
	if l == r:
		if int(r) % 2 == 0:
			print(r)
		else:
			print(int(r) * -1)
	else:
		suma = sum_even(int(l), int(r)) - sum_odd(int(l), int(r))
		print(suma)


def solve(i, k):
	negative_start = None
	negative_end = None
	if i % 2 == 1:
		negative_start = i
	elif i + 1 <= k:
		negative_start = i + 1
	if k % 2 == 1:
		negative_end = k
	elif k - 1 >= i:
		negative_end = k - 1
	positive_start = None
	positive_end = None
	if i % 2 == 0:
		positive_start = i
	elif i + 1 <= k:
		positive_start = i + 1
	if k % 2 == 0:
		positive_end = k
	elif k - 1 >= i:
		positive_end = k - 1
	solution = 0
	if negative_start is not None and negative_end is not None:
		elements = 1 + (negative_end - negative_start) // 2
		solution += -1 * (negative_start + negative_end) * elements // 2
	if positive_start is not None and positive_end is not None:
		elements = 1 + (positive_end - positive_start) // 2
		solution += (positive_start + positive_end) * elements // 2
	return solution
n = int(input())
for _ in range(n):
	(i, k) = map(int, input().split())
	print(solve(i, k))


t = int(input())
for x in range(t):
	l1 = [int(x) for x in input().split()]
	low = l1[0]
	high = l1[1]
	if low % 2:
		if high % 2:
			print(-low - (high - low) // 2)
		else:
			print((high - low + 1) // 2)
	elif high % 2:
		print(-(high - low + 1) // 2)
	else:
		print(low + (high - low) // 2)


__author__ = 'tanunia'
from sys import stdin
q = int(stdin.readline())
for _ in range(q):
	(l, r) = [int(x) for x in stdin.readline().split()]
	res = 0
	if l % 2 == 0:
		res += l
		l += 1
	if r % 2 == 1:
		res -= r
		r -= 1
	res += (r - l + 1) / 2
	print(int(res))


def findSum(x):
	oddCount = -(-x // 2)
	evenCount = x - oddCount
	oddSum = oddCount * oddCount
	evenSum = evenCount * (evenCount + 1)
	return evenSum - oddSum
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	print(findSum(r) - findSum(l - 1))


import math
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	if l % 2 == 0 and r % 2 == 0:
		nn = (r - l) // 2 + 1
		se = nn * (2 * l + (nn - 1) * 2)
		no = (r - l - 2) // 2 + 1
		so = no * (2 * (l + 1) + (no - 1) * 2)
		se = se // 2
		so = so // 2
		print(se - so)
		continue
	if l % 2 == 0 and r % 2 == 1:
		nn = (r - l) // 2 + 1
		se = nn * (2 * l + (nn - 1) * 2)
		no = (r - l - 1) // 2 + 1
		so = no * (2 * (l + 1) + (no - 1) * 2)
		se = se // 2
		so = so // 2
		print(se - so)
		continue
	if l % 2 == 1 and r % 2 == 0:
		nn = (r - l) // 2 + 1
		se = nn * (2 * (l + 1) + (nn - 1) * 2)
		se = se // 2
		no = (r - l - 1) // 2 + 1
		so = no * (2 * l + (no - 1) * 2)
		so = so // 2
		print(se - so)
		continue
	if l % 2 == 1 and r % 2 == 1:
		nn = (r - l - 2) // 2 + 1
		se = nn * (2 * (l + 1) + (nn - 1) * 2)
		se = se // 2
		no = (r - l) // 2 + 1
		so = no * (2 * l + (no - 1) * 2) // 2
		print(se - so)
		continue


for u in range(int(input())):
	(x, y) = map(int, input().split())
	s = 0
	if y % 2 == 0:
		s = s + y // 2
	else:
		s = s + (y // 2 - y)
	x = x - 1
	if x % 2 == 0:
		s = s - x // 2
	else:
		s -= x // 2 - x
	print(s)


q = int(input())
x = lambda l: -(l + 1) // 2 if l & 1 else l // 2
for _ in range(q):
	(a, b) = map(int, input().split())
	print(x(b) - x(a - 1))


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


for i in range(int(input())):
	(l, r) = map(int, input().split())
	a = r // 2
	a = a * (a + 1)
	b = (l - 1) // 2
	b = b * (b + 1)
	even = a - b
	a = r // 2 + r % 2
	a = a * a
	b = (l - 1) // 2 + (l - 1) % 2
	b = b * b
	odd = a - b
	print(even - odd)


def F(x):
	if x % 2 == 0:
		return x // 2
	else:
		return -x + F(x - 1)

def main():
	num_of_rows = int(input().strip())
	for i in range(num_of_rows):
		(first_num, last_num) = map(int, input().split())
		print(F(last_num) - F(first_num - 1))
main()


def suma(n):
	return n * (n + 1) // 2

def sumpri(l, r):
	if r % 2 != 0:
		r += 1
	if l % 2 == 0:
		l += 1
	x = suma(r) - suma(l - 1)
	x -= (r - l + 1) // 2
	return x // 2
from sys import stdin
n = int(stdin.readline().strip())
for i in range(n):
	(l, r) = map(int, stdin.readline().strip().split())
	print(suma(r) - suma(l - 1) - 2 * sumpri(l, r))


f = lambda : map(int, input().split())
n = int(input())
for i in range(n):
	s1 = s2 = 0
	(a, b) = f()
	if a == b:
		print(a * (-1) ** a)
	elif a % 2 == 0 and b % 2 == 0:
		print(b - (b - a) // 2)
	elif a % 2 != 0 and b % 2 != 0:
		print(-b + (b - a) // 2)
	elif a % 2 == 0 and b % 2 != 0:
		print(-(b - a + 1) // 2)
	else:
		print((b - a + 1) // 2)


t = int(input())
ans = []
for _ in range(t):
	(l, r) = map(int, input().split(' '))
	if l % 2 == 0:
		s1 = l // 2 * (l // 2 + 1) - (l // 2) ** 2 - l
	else:
		s1 = (l - 1) // 2 * ((l - 1) // 2 + 1) - ((l + 1) // 2) ** 2 + l
	if r % 2 == 0:
		s2 = r // 2 * (r // 2 + 1) - (r // 2) ** 2
	else:
		s2 = (r - 1) // 2 * ((r - 1) // 2 + 1) - ((r + 1) // 2) ** 2
	ans.append(s2 - s1)
print(*ans, sep='\n')


from math import ceil

def main():
	q = int(input())
	res = []
	for _ in range(q):
		(l, r) = map(int, input().split())
		acc_r = ceil(r / 2) * (-1) ** r
		acc_l = 0 if l == 1 else ceil((l - 1) / 2) * (-1) ** (l - 1)
		res.append(str(acc_r - acc_l))
	print('\n'.join(res))
main()


from collections import defaultdict

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
q = int(input())
for _ in range(q):
	(l, r) = read_line()
	print(query(l, r))


def value(x, y):
	n1 = not bool(x % 2)
	n2 = not bool(y % 2)
	if n1 == n2:
		if n1:
			s = -((y - x) // 2) + y
		else:
			s = (y - x) // 2 - y
	elif n1:
		s = -((y - x) // 2 + 1)
	else:
		s = (y - x) // 2 + 1
	return s
n = int(input())
for i in range(n):
	(q, l) = map(int, input().split())
	print(value(q, l))


def margariteAndTheBestPresent(q):
	for i in range(q):
		(l, r) = map(int, input().split())
		al = (-1) ** l * (2 * l - 1)
		ar = (-1) ** r * (2 * r + 1)
		f = (al + ar) // 4
		print(f)

def main():
	q = int(input())
	margariteAndTheBestPresent(q)
main()


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


def mult(i):
	if i % 2 == 0:
		return i
	else:
		return -i

def solve(l, r):
	s1 = solve_slow(l, r)
	s2 = solve_fast(l, r)
	assert s1 == s2

def solve_slow(l, r):
	s = sum((mult(i) for i in range(l, r + 1)))
	return s

def solve_fast(l, r):
	nl = l // 2 * 2 + 1
	nr = r // 2 * 2
	btw = (nr - nl) // 2 + 1
	s = btw + solve_slow(l, nl - 1) + solve_slow(nr + 1, r)
	return s
q = int(input())
for i in range(q):
	(l, r) = map(int, input().split())
	print(solve_fast(l, r))


T = int(input())
for case in range(T):
	ans = 0
	(l, r) = map(int, input().split())
	lenth = r - l + 1
	if lenth & 1:
		half = lenth // 2
		if l & 1:
			ans += half
			ans -= r
		else:
			ans -= half
			ans += r
	else:
		half = lenth // 2
		if l & 1:
			ans += half
		else:
			ans -= half
	print(ans)


fn = lambda n: n // 2 if n % 2 == 0 else -(n + 1) // 2

def f(ll):
	(l, r) = ll
	return fn(r) - fn(l - 1)
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	print(f(l))


num = int(input())
ls = []
for i in range(num):
	(n, k) = map(int, input().split())
	ls.append([n, k])
for j in range(len(ls)):
	if ls[j][0] == ls[j][1]:
		if ls[j][0] % 2 == 0:
			print(ls[j][0])
		else:
			print(-ls[j][0])
	elif ls[j][0] % 2 == 0 and ls[j][1] % 2 == 0:
		print(-(ls[j][1] - ls[j][0]) // 2 + ls[j][1])
	elif ls[j][0] % 2 == 1 and ls[j][1] % 2 == 0:
		print(-(ls[j][1] - ls[j][0] - 1) // 2 + ls[j][1] - ls[j][0])
	elif ls[j][0] % 2 == 1 and ls[j][1] % 2 == 1:
		print(-(ls[j][1] - ls[j][0]) // 2 - ls[j][0])
	elif ls[j][0] % 2 == 0 and ls[j][1] % 2 == 1:
		print(int(-(ls[j][1] - ls[j][0] - 1) / 2 - 1))


n = int(input())
ou = ''
for i in range(n):
	(l, r) = map(int, input().split())
	(bef, end) = (0, 0)
	l -= 1
	if l % 2 == 0:
		bef = int(l / 2)
	else:
		bef = int((l + 1) / 2) * -1
	if r % 2 == 0:
		end = int(r / 2)
	else:
		end = int((r + 1) / 2) * -1
	ou += '%s\n' % (end - bef)
print(ou)


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:
		lc = l if l % 2 == 0 else l + 1
		rc = r if r % 2 == 0 else r - 1
		nc = (rc - lc) // 2 + 1
		nn = r - l - nc + 1
		f1 = l if l % 2 == 0 else l + 1
		s1 = (f1 + (nc - 1)) * nc
		f2 = l if l % 2 else l + 1
		s2 = (f2 + (nn - 1)) * nn
		print(s1 - s2)


n = int(input())
ans = 0
for i in range(n):
	(f, s) = list(map(int, input().split()))
	if f == s:
		print(s * (-1) ** s)
		continue
	if f % 2 == 1:
		if s % 2 == 1:
			ans = (s - f) // 2 + s * (-1) ** s
		if s % 2 == 0:
			ans = (s - f + 1) // 2
	if f % 2 == 0:
		if s % 2 == 0:
			ans = -((s - f) // 2) + s * (-1) ** s
		if s % 2 == 1:
			ans = -((s - f + 1) // 2)
	print(ans)