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: 25312kB
Author: 13777799015
In contest: 1295

for count 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 hh_count in range(n):
        hh_s,hh_e=map(int,input().split())
        #a[j]=[1] for j in range(hh_s,hh_e+1)
        a[hh_s:hh_e+1]=[1]*(hh_e-hh_s+1)
    for dd_count in range(m):
        dd_s,dd_e=map(int,input().split())
        #b[i]=[1] for i in range(dd_s,dd_e+1)
        b[dd_s:dd_e+1]=[1]*(dd_e-dd_s+1)

    total = 0
    for i in range(24):
        total=total+b[i]*a[i]
    print(total)