5
OIL
PFJMFWXRQYXBNJNTWIZVSRJIKPGIWEWN
UCWHELOLFDGGPYKMZ
CGHEAXJAMRSMDDNOJEFAOFVPAIVNSGJG
ZLOGAPUZTOHKFQGKSRSNFYVVQTIQMRJBSVOY
J
FYLI
WFSKQDNKTRHXZJC
COOGCEZEXKOZZQMKLLTTIL
0
0
0
0
0

for _ in range(input()):
	try:n=raw_input()
	except:n=raw_input()
	try:a=raw_input()
	except:
		try:a=raw_input()
		except:
			print 0
			continue
	ans=0
	i=0
	while i<len(n) and i<len(a):
		if n[i]==a[i]:ans+=1
		i+=1
	print ans