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: 76ms
Memory: 25312kB
Author: 18989493100
In contest: 1295

hht=[]
dt=[]
s=0

for i in range(int(input())):
    n,m=map(int,input().split())
    for j in range(n):
        a,b=map(int,input().split())
        for hh in range (a,b+1):
            if hh not in hht:
                hht.append(hh)
    
    for k in range(m):
        c,d=map(int,input().split())
        for e in range(c,d+1):
            if e not in dt:
                dt.append(e)
    
    for t in hht:
        if t in dt:
            s+=1
            
    print(s)
    s=0
    hht=[]
    dt=[]