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

t=int(raw_input())
while t:
	t-=1
	x=raw_input()
	try:
		y=raw_input()
			
		n=min(len(x),len(y))
		cnt=0
		for i in xrange(n):
			if x[i] == y[i]:
				cnt+=1
		print cnt
	
	except:
		print 0
		pass