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: 77ms
Memory: 25316kB
Author: shanzhenyu
In contest: 1295

def getData(n):
    a = set()
    for i in range(n):
        s,e = map(int,input().split())
        a |= set([i for i in range(s,e+1)])
    return a

for tcase in range(int(input())):
    n,m = map(int,input().split())
    a,b = getData(n),getData(m)    
    print(len(a&b))