n=int(eval(input()))

ans=0

for i in range(n):

    ans+=~(eval(input().replace(' ','-')))+2

print(ans)
# https://atcoder.jp/contests/abc073/tasks/abc073_b



n=int(eval(input()))

lr=[tuple(map(int,input().split())) for _ in range(n)]

ans=0

for l,r in lr:

    ans+=r-l+1

print(ans)
n = int(eval(input()))
ans = 0
for i in range(n):
    ans += ~(eval(input().replace(" ", "-"))) + 2
print(ans)

# https://atcoder.jp/contests/abc073/tasks/abc073_b
n = int(eval(input()))
lr = [tuple(map(int, input().split())) for _ in range(n)]
ans = 0
for l, r in lr:
    ans += r - l + 1
print(ans)

+# https://atcoder.jp/contests/abc073/tasks/abc073_b +lr = [tuple(map(int, input().split())) for _ in range(n)] -for i in range(n): -    ans += ~(eval(input().replace(" ", "-"))) + 2 +for l, r in lr: +    ans += r - l + 1