Start: Nov, 12, 2017 10:00:00
2017秋Python程序设计基础培训第三次作业
End: Nov, 19, 2017 12:00:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 102ms
Memory: 24436kB
Author: zhuzhu
In contest: 1123

def rddata(n):
	a = [0 for i in range(24)]
	for i in range(n):
		s,e = map(int,input().split())
		for j in range(s,e+1):
			a[j] = 1
	return a;
x = int(input())
for t in range(x):
	n,m = map(int,input().split())    
	a,b=rddata(n),rddata(m)
	sum=0
	for i in range(24):
		if a[i] == 1 and b[i] == 1:
			sum += 1
	print(sum)