text: # included from snippets/main.py
  def debug(*x, msg=""):
      import sys
      print(msg, *x, file=sys.stderr)
  
  
  def solve(SOLVE_PARAMS):
      pass
  
  
  def getTriangleNumber(n, when_negative=None):
      if n < 0:
          if when_negative is None:
              raise AssertionError("arg should not be negative")
          return when_negative
      return n * (n + 1) // 2
  
  
  def main():
      T = int(input())
      for _i in range(T):
          L, R = map(int, input().split())
          print(getTriangleNumber(R - 2 * L + 1, 0))
  
  
  # tests
  T1 = """
  5
  2 6
  0 0
  1000000 1000000
  12345 67890
  0 1000000
  """
  TEST_T1 = """
  >>> as_input(T1)
  >>> main()
  6
  1
  0
  933184801
  500001500001
  """
  
  
  def _test():
      import doctest
      doctest.testmod()
      g = globals()
      for k in sorted(g):
          if k.startswith("TEST_"):
              print(k)
              doctest.run_docstring_examples(g[k], g, name=k)
  
  
  def as_input(s):
      "use in test, use given string as input file"
      import io
      f = io.StringIO(s.strip())
      g = globals()
      g["input"] = lambda: bytes(f.readline(), "ascii")
      g["read"] = lambda: bytes(f.read(), "ascii")
  
  
  if __name__ == "__main__":
      import sys
      input = sys.stdin.buffer.readline
      read = sys.stdin.buffer.read
      sys.setrecursionlimit(10 ** 6)
      if sys.argv[-1] == "-t":
          print("testing")
          _test()
          sys.exit()
      main()
      sys.exit()
  
  # end of snippets/main.py
  