Start: Jul, 17, 2019 00:00:00
20190717Python程序设计基础培训第三次作业
End: Jul, 21, 2019 00:00:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 48ms
Memory: 25316kB
Author: 15258406436
In contest: 1295

for t in range(int(input())):
    n,m = map(int,input().split())
    a,b = [0 for i in range(24)],[0 for i in range(24)]
    for i in range(n):
        s,e = map(int,input().split())
        a[s:e+1] = [1]*(e-s+1)
    for i in range(m):
        s,e = map(int,input().split())
        b[s:e+1] = [1]*(e-s+1)
    total = 0
    for i in range(24):
        if a[i]==1 and b[i]==1:
            total+=1
    print(total)