Did you know that there are over 40,000 varieties of Rice in the world ? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his newly designed blog for community voting, where a user can plus (+) or minus (-) the recipe. The final score is just the sum of all votes, where (+) and (-) are treated as +1 and -1 respectively. But, being just a chef ( and not a codechef ) he forgot to take care of multiple votes by the same user.

A user might have voted multiple times and Tid is worried that the final score shown is not the correct one. Luckily, he found the user logs, which had all the N votes in the order they arrived.  Remember that, if a user votes more than once, the user's previous vote is first nullified before the latest vote is counted ( see explanation for more clarity ). Given these records in order ( and being a codechef yourself :) ), calculate the correct final score.

------ Input ------ 

First line contains T ( number of testcases, around 20 ). T cases follow. Each test case starts with N ( total number of votes, 1 ≤ N ≤ 100 ). Each of the next N lines is of the form "userid vote" ( quotes for clarity only ), where userid is a non-empty string of lower-case alphabets ( 'a' - 'z' ) not more than 20 in length and vote is either a + or - . See the sample cases below, for more clarity.

------ Output ------ 

For each test case, output the correct final score in a new line

----- Sample Input 1 ------ 
3
4
tilak +
tilak +
tilak -
tilak +
3
ratna +
shashi -
ratna -
3
bhavani -
bhavani +
bhavani -
----- Sample Output 1 ------ 
1
-2
-1
----- explanation 1 ------ 
Case 1 : Initially score = 0. Updation of scores in the order of user tilak's votes is as follows,
( + ): +1 is added to the final score. This is the 1st vote by this user, so no previous vote to nullify. score = 1
( + ):  0 should be added ( -1 to nullify previous (+) vote, +1 to count the current (+) vote ). score = 1
( - ) : -2 should be added ( -1 to nullify previous (+) vote, -1 to count the current (-) vote ). score = -1
( + ): +2 should be added ( +1 to nullify previous (-) vote, +1 to count the current (+) vote ). score = 1

Difficulty: EASY

Solutions:
for tc in range(int(input())):
	kmap = {}
	n = int(input())
	count = 0
	for i in range(n):
		(name, sign) = map(str, input().split())
		if name not in kmap:
			kmap[name] = sign
			count += 1 if sign == '+' else -1
		elif sign != kmap[name]:
			kmap[name] = sign
			count += 2 if sign == '+' else -2
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	m = []
	j = 0
	k = 0
	while k < n:
		(s, p) = input('').split()
		if s not in l:
			l.append(s)
			m.append(p)
			j = j + 1
		if s in l:
			re = l.index(s)
			m[re] = p
		k = k + 1
	count = 0
	print(m.count('+') - m.count('-'))


t = int(input())
for i in range(t):
	n = int(input())
	d = {}
	for j in range(n):
		s = input().split()
		if s[1] == '+':
			d[s[0]] = 1
		else:
			d[s[0]] = -1
	ans = 0
	for x in d:
		ans += int(d[x])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	yup = {}
	for _ in range(n):
		(name, vote) = input().split()
		yup[name] = vote
	votes = 0
	for i in yup.values():
		if i == '+':
			votes += 1
		else:
			votes -= 1
	print(votes)


for tc in range(int(input())):
	n = int(input())
	s = []
	for i in range(n):
		s.append(input().split())
	votes = {}
	for vote in s:
		votes[vote[0]] = vote[1]
	cnt = 0
	for name in votes.keys():
		if votes[name] == '+':
			cnt += 1
		else:
			cnt -= 1
	print(cnt)


a = int(input(''))
for i in range(a):
	x = int(input(''))
	t = {}
	for j in range(x):
		(u, v) = input().split()
		t.update({u: v})
	c = 0
	for h in t.values():
		if h == '+':
			c = c + 1
		else:
			c = c - 1
	print(c)


a = int(input())
for i in range(a):
	l1 = []
	n = int(input())
	for j in range(n):
		l1.append(input().split(' '))
	l1.reverse()
	summ = 0
	name = []
	for j in range(n):
		if l1[j][0] not in name:
			name.append(l1[j][0])
			summ += 1 if l1[j][1] == '+' else -1
	print(summ)


for _ in range(int(input())):
	N = int(input())
	dct = dict()
	for __ in range(N):
		x = input().split()
		userid = x[0]
		vote = int(x[1] == '+')
		if vote == 0:
			vote = -1
		dct[userid] = vote
	print(sum(dct.values()))


(inp, i) = (int(input()), 1)
(j, d, li) = (1, {}, [])
while i <= inp:
	try:
		n = int(input())
		for j in range(n):
			users = input().split()
			if users[1] == '+':
				users[1] = 1
			else:
				users[1] = -1
			d[users[0]] = users[1]
		li = list(d.values())
		print(sum(li))
		li = []
		d = {}
		i += 1
	except EOFError:
		break


def solve():
	n = int(input())
	d = {}
	count = 0
	for _ in range(n):
		(ide, score) = input().split()
		d[ide] = score
	for v in d.values():
		if v == '+':
			count = count + 1
		else:
			count = count - 1
	print(count)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	arr = dict()
	sm = 0
	for i in range(n):
		(name, vote) = input().split()
		if vote == '-':
			arr.update({name: -1})
		else:
			arr.update({name: +1})
	print(sum(list(arr.values())))


for _ in range(int(input())):
	votes = dict()
	for _ in range(int(input())):
		(name, type) = input().split()
		votes[name] = type
	print(list(votes.values()).count('+') - list(votes.values()).count('-'))


t = int(input())
for i in range(t):
	n = int(input())
	d = dict()
	for i in range(n):
		s = input().split()
		d[s[0]] = s[1]
	s = list(d.values())
	s1 = s.count('+')
	s2 = s.count('-')
	print(s1 - s2)


n = int(input())
for i in range(n):
	m = {}
	l = int(input())
	for j in range(l):
		q = input().split()
		if q[1] == '+':
			m[q[0]] = 1
		else:
			m[q[0]] = -1
	f = list(m.values())
	print(sum(f))


T = int(input())
for i in range(T):
	n = int(input())
	a = {}
	b = 0
	for j in range(n):
		c = str(input()).split(' ')
		if c[0] in a.keys():
			if a[c[0]] == '+':
				d = -1
			else:
				d = 1
			if c[1] == '+':
				d = d + 1
			else:
				d = d - 1
			b = b + d
			a[c[0]] = c[1]
		else:
			if c[1] == '+':
				d = 1
			else:
				d = -1
			b = b + d
			a[c[0]] = c[1]
	print(b)


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(input())
	l = l[::-1]
	r = []
	s = 0
	for i in l:
		(a, b) = i.split(' ')
		if a not in r:
			r.append(a)
			if b == '-':
				s -= 1
			else:
				s += 1
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	a.reverse()
	cnt = 0
	lst = []
	for i in a:
		if i[:-1] not in lst:
			lst.append(i[:-1])
			if i[-1:] == '+':
				cnt += 1
			else:
				cnt -= 1
	print(cnt)


for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(n):
		elem = [j for j in input().split()]
		arr.append(elem)
	mp = {}
	for i in range(n):
		if arr[i][0] in mp:
			mp[arr[i][0]] = arr[i][-1]
		else:
			mp[arr[i][0]] = arr[i][-1]
	res = 0
	for val in mp.values():
		if val == '-':
			res -= 1
		else:
			res += 1
	print(res)


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(input().split())
	d = {}
	for i in range(n):
		d[l[i][0]] = l[i][1]
	c = 0
	for i in d.values():
		if i == '+':
			c += 1
		else:
			c -= 1
	print(c)


for i in range(int(input())):
	c = 0
	d = {}
	for j in range(int(input())):
		(x, y) = input().split()
		d[x] = y
	for k in d:
		if d[k] == '-':
			c -= 1
		else:
			c += 1
	print(c)


t = int(input())
while t != 0:
	n = int(input())
	d = dict()
	for _ in range(0, n):
		(a, v) = input().split()
		d[a] = v
	s = 0
	for _ in d:
		if d[_] == '+':
			s += 1
		else:
			s += -1
	print(s)
	t -= 1


for _ in range(int(input())):
	dy = {}
	c = 0
	for _ in range(int(input())):
		(x, y) = map(str, input().split())
		dy[x] = y
	for i in dy.values():
		if i == '-':
			c -= 1
		else:
			c += 1
	print(c)


for _ in range(int(input())):
	x = int(input())
	dic = {}
	for i in range(x):
		(a, b) = map(str, input().split())
		dic.update({a: b})
	t = list(dic.values())
	c = 0
	for i in t:
		if i == '+':
			c += 1
		else:
			c -= 1
	print(c)


n = int(input())
inputs = []
for i in range(n):
	tmp = int(input())
	inputs.append([])
	for i in range(tmp):
		inputs[-1].append(input().split())

def answer(i):
	lastVote = {}
	for j in range(len(i)):
		lastVote[i[j][0]] = 1 if i[j][1] == '+' else -1
	return sum(list(lastVote.values()))
for i in inputs:
	print(answer(i))


for _ in range(int(input())):
	d = {}
	for N in range(int(input())):
		(a, b) = input().split()
		d[a] = int(b + '1')
	print(sum(list(d.values())))


for _ in range(int(input())):
	n = int(input())
	d = {}
	for i in range(n):
		s = input().split()
		if s[1] == '+':
			d[s[0]] = 1
		else:
			d[s[0]] = -1
	c = 0
	for x in d:
		c += int(d[x])
	print(c)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	dict = {}
	for i in range(n):
		(user_id, op) = list(map(str, input().split()))
		dict[user_id] = op
	for (user_id, op) in dict.items():
		if op == '+':
			ans += 1
		else:
			ans -= 1
	print(ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = {}
	for i in range(0, n):
		(name, id) = input().split()
		a[name] = id
	s = 0
	for (i, j) in a.items():
		if j == '+':
			s = s + 1
		elif j == '-':
			s = s - 1
	print(s)


tests = int(input())
for i in range(tests):
	length = int(input())
	votes_dict = {}
	ans = 0
	for x in range(length):
		(name, vote) = input().split()
		if vote == '-':
			temp_vote = -1
		else:
			temp_vote = 1
		if name in votes_dict:
			if votes_dict[name] != temp_vote:
				votes_dict[name] = temp_vote
				ans += temp_vote * 2
		else:
			votes_dict[name] = temp_vote
			ans += temp_vote
	print(ans)


T = int(input())
for i in range(T):
	N = int(input())
	userAll = []
	scoreUser = []
	for i in range(N):
		testInput = input().split()
		user = testInput[0]
		score = testInput[1]
		if user not in userAll:
			userAll.append(user)
			if score == '+':
				scoreUser.append(1)
			else:
				scoreUser.append(-1)
		elif score == '+':
			scoreUser[userAll.index(user)] = 1
		else:
			scoreUser[userAll.index(user)] = -1
	totalScore = 0
	for i in range(len(scoreUser)):
		totalScore += scoreUser[i]
	print(totalScore)


for i in range(int(input())):
	n = int(input())
	(n1, s) = ([], [])
	sm = 0
	for i in range(n):
		(a, b) = map(str, input().split())
		n1.append(a)
		s.append(b)
	l1 = set(n1)
	l4 = list(l1)
	l2 = n1[::-1]
	l3 = s[::-1]
	for i in range(len(l4)):
		ind = l2.index(l4[i])
		if l3[ind] == '+':
			sm = sm + 1
		else:
			sm = sm - 1
	print(sm)


for _ in range(int(input())):
	d = {}
	n = int(input())
	for i in range(n):
		s = input().split()
		if s[1] == '+':
			d[s[0]] = 1
		else:
			d[s[0]] = -1
	l = list(d.values())
	print(sum(l))


t = int(input())
for i in range(t):
	n = int(input())
	dict = {}
	for iterate in range(n):
		(n, v) = list(map(str, input().split()))
		dict[n] = v
	score = 0
	for (n, v) in dict.items():
		if v == '+':
			score += 1
		else:
			score -= 1
	print(score)


for i in range(int(input())):
	n = int(input())
	t = {}
	for u in range(n):
		e = input()
		f = e[-1]
		l = e[:-1]
		t.update({l: f})
	q = t.values()
	qq = list(q)
	jj = 0
	for b in qq:
		if b == '-':
			pp = -1
		else:
			pp = 1
		jj = jj + pp
	print(jj)


for _ in range(int(input())):
	n = int(input())
	d = {}
	for i in range(n):
		(idi, s) = map(str, input().split())
		d[idi] = s
	ans = 0
	for (key, value) in d.items():
		if value == '+':
			ans += 1
		elif value == '-':
			ans -= 1
	print(ans)


t = int(input())
while t > 0:
	a = {}
	n = int(input())
	for i in range(n):
		s = input().split()
		if s[1] == '+':
			a[s[0]] = 1
		else:
			a[s[0]] = -1
	b = a.values()
	print(sum(b))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	lst = []
	lst1 = []
	for i in range(n):
		s = str(input())
		if s[-1] == '+':
			lst1.append(1)
		elif s[-1] == '-':
			lst1.append(-1)
		lst.append(s[:len(s) - 2])
	lst.reverse()
	lst1.reverse()
	d = {}
	for i in range(len(lst)):
		if lst[i] not in d:
			d[lst[i]] = lst1[i]
	s = 0
	for i in d:
		s += d[i]
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = []
	m = []
	for i in range(n):
		(id, vote) = map(str, input().split())
		l.append(id)
		if vote == '+':
			m.append(1)
		else:
			m.append(-1)
	dictio = dict(zip(l, m))
	li = list(dictio.values())
	print(sum(li))


for i in range(int(input())):
	n = int(input())
	(l1, l2, l5, l6) = ([], [], [], [])
	for i in range(n):
		(x, y) = input().split()
		l1.append(x)
		l2.append(y)
	l3 = l1[::-1]
	l4 = l2[::-1]
	for (x, y) in zip(l3, l4):
		if x not in l5:
			l5.append(x)
			l6.append(y)
	r1 = l6.count('+')
	r2 = l6.count('-')
	print(r1 - r2)


t = int(input())
while t:
	n = int(input())
	d = {}
	for i in range(n):
		l = input().split()
		d[l[0]] = 1 if l[1] == '+' else -1
	ans = 0
	for i in d:
		if d[i] == 1:
			ans += 1
		else:
			ans -= 1
	print(ans)
	t -= 1


for t in range(int(input())):
	n = int(input())
	j = []
	l = []
	for i in range(n):
		(s, k) = map(str, input().split())
		l.append(s)
		l.append(k)
		j.append(s)
	j = list(set(j))
	l = l[::-1]
	p = []
	for i in j:
		q = l.index(i)
		p.append(l[q - 1])
	ans = 0
	for i in p:
		if i == '+':
			ans += 1
		else:
			ans -= 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	new_list = []
	for i in range(n):
		s = input().split()
		new_list.append(s)
	dict_a = {}
	for char in new_list:
		if char[0] in dict_a:
			dict_a[char[0]] += char[1]
		else:
			dict_a[char[0]] = char[1]
	result = []
	for (key, value) in dict_a.items():
		result.append(value[-1])
	r = 0
	for char in result:
		if char == '+':
			r += 1
		elif char == '-':
			r -= 1
	print(r)


for _ in range(int(input())):
	x = int(input())
	l = []
	m = []
	sum = 0
	for i in range(x):
		(a, b) = map(str, input().split())
		l.append(a)
		m.append(b)
	g = list(set(l))
	l.reverse()
	for i in range(len(g)):
		res = l.index(g[i])
		res = len(l) - res - 1
		if m[res] == '+':
			sum += 1
		else:
			sum -= 1
	print(sum)


for _ in range(int(input())):
	n = int(input())
	user_ids = {}
	votes = 0
	for i in range(n):
		(user, vote) = input().split()
		user_ids[user] = 1 if vote == '+' else -1
	votes = sum(user_ids.values())
	print(votes)


t = int(input())
for i in range(t):
	n = int(input())
	dic = {}
	for j in range(n):
		vote = input().split(' ')
		if vote[1] == '+':
			dic.update({vote[0]: 1})
		else:
			dic.update({vote[0]: -1})
	print(sum(list(dic.values())))


from sys import stdin, stdout

def scan():
	return stdin.readline().strip()

def scanm():
	return map(int, scan().split())

def out(s):
	return stdout.write(str(s) + '\n')
for _ in range(int(scan())):
	d = {}
	for i in range(int(scan())):
		temp = scan().split()
		d[temp[0]] = 1 if temp[1] == '+' else -1
	print(sum(d.values()))


t = input()
for c in range(0, int(t)):
	n = input()
	names = []
	votes = []
	inn = 0
	count = 0
	for x in range(0, int(n)):
		vote = input().split()
		inn = 0
		for y in range(0, len(names)):
			if vote[0] == names[y]:
				count = count - votes[y]
				if vote[1] == '+':
					count = count + 1
					votes[y] = 1
				elif vote[1] == '-':
					count = count - 1
					votes[y] = -1
				inn = 1
				break
		if inn == 0:
			names.append(vote[0])
			if vote[1] == '+':
				count = count + 1
				votes.append(1)
			elif vote[1] == '-':
				count = count - 1
				votes.append(-1)
	print(count)


T = int(input())
if T >= 1 and T <= 20:
	M = []
	for i in range(0, T):
		votes = {}
		N = int(input())
		if N >= 1 and N <= 100:
			for i in range(0, N):
				(name, point) = input().split()
				if point == '+':
					votes[name] = 1
				elif point == '-':
					votes[name] = -1
			M.append(sum(votes.values()))
	for i in range(0, T):
		print(M[i])


for _ in range(int(input())):
	n = int(input())
	l1 = []
	dick = {}
	for _ in range(n):
		(u, v) = map(str, input().split())
		if u not in l1:
			l1.append(u)
			dick[u] = v
		else:
			dick[u] = v
	c = 0
	for val in dick:
		if dick[val] == '+':
			c += 1
		else:
			c -= 1
	print(c)


T = int(input())
for t in range(T):
	n = int(input())
	d = {}
	for i in range(n):
		(v_id, vote) = input().split()
		d[v_id] = vote
	votes = 0
	for i in d.values():
		if i == '+':
			votes += 1
		else:
			votes -= 1
	print(votes)


for i in range(int(input())):
	n = int(input())
	voted = []
	total = 0
	curvotes = []
	curnames = []
	for i in range(n):
		inp = input().split()
		name = inp[0]
		votet = inp[1]
		curnames.append(name)
		curvotes.append(votet)
	for i in range(len(curvotes)):
		if curnames[n - 1 - i] not in voted:
			voted.append(curnames[n - 1 - i])
			if curvotes[n - 1 - i] == '+':
				total += 1
			else:
				total -= 1
	print(total)


t = int(input())
for ni in range(t):
	n = int(input())
	count = 0
	d = dict()
	x = 0
	for ki in range(n):
		(a, b) = input().split()
		if b == '+':
			x = 1
		else:
			x = -1
		d[a] = x
	for i in d.values():
		count = count + i
	print(count)


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	s = []
	for j in range(n):
		(a, b) = input().split()
		l.append(a)
		s.append(b)
	se = set(l)
	l = l[::-1]
	s = s[::-1]
	res = 0
	for i in se:
		if s[l.index(i)] == '+':
			res = res + 1
		else:
			res = res - 1
	print(res)


for _ in range(int(input())):
	n = int(input())
	votes = {}
	for i in range(n):
		(user, rate) = input().split()
		votes[user] = rate
	s = 0
	for (key, values) in votes.items():
		if values == '+':
			s += 1
		else:
			s -= 1
	print(s)


for _ in range(int(input())):
	n = int(input())
	d = {}
	for i in range(n):
		s = input()
		(a, b) = s.split(' ')
		d[a] = b
	print(list(d.values()).count('+') - list(d.values()).count('-'))


def main():
	for _ in range(int(input())):
		N = int(input())
		D = dict()
		for i in range(N):
			x = input().split()
			D[x[0]] = 1 if x[1] == '+' else -1
		print(sum(list(D.values())))
main()


t = int(input())
for i in range(t):
	n = int(input())
	votes_dic = dict()
	for j in range(n):
		(name, vote) = list(input().split(' '))
		if vote == '+':
			vote = 1
		else:
			vote = -1
		votes_dic[name.lower()] = vote
	print(sum(votes_dic.values()))


for _ in range(int(input())):
	N = int(input())
	d = {}
	for i in range(N):
		xx = input()
		d[xx[:-2]] = int(xx[-1] + '1')
	print(sum(list(d.values())))


t = int(input())
d = {}
while t:
	n = int(input())
	l = []
	s = 0
	for i in range(n):
		(a, b) = input().split()
		l.append(a)
		l.append(b)
	d = {l[x]: l[x + 1] for x in range(0, 2 * n, 2)}
	for j in d:
		if d[j] == '+':
			s += 1
		else:
			s -= 1
	print(s)
	t -= 1


for t in range(int(input())):
	n = int(input())
	s = {}
	for i in range(n):
		(a, b) = input().split()
		s.update({a: b})
	c = 0
	for j in s.values():
		if j == '+':
			c += 1
		else:
			c -= 1
	print(c)


t = int(input())
for j in range(t):
	n = int(input())
	l = []
	m = []
	for i in range(n):
		(user, vote) = map(str, input().split())
		l.append(user)
		if vote == '+':
			m.append(1)
		else:
			m.append(-1)
	ans1 = dict(zip(l, m))
	ans = list(ans1.values())
	print(sum(ans))


for t in range(int(input())):
	n = int(input())
	d = {}
	s = 0
	for i in range(n):
		(x, y) = map(str, input().split(' '))
		d[x] = y
	l = list(d.values())
	c1 = l.count('-')
	c2 = l.count('+')
	s = c2 - c1
	print(s)


T = int(input())
for _ in range(T):
	n = int(input())
	d = {}
	for i in range(n):
		(name, p) = map(str, input().split())
		d[name] = p
	total = 0
	for ele in d:
		if d[ele] == '+':
			total += 1
		else:
			total -= 1
	print(total)


t = int(input())
for tc in range(t):
	m = int(input())
	x = []
	y = []
	for j in range(m):
		(s, n) = map(str, input().split())
		x.append(s)
		if n == '+':
			y.append(+1)
		elif n == '-':
			y.append(-1)
	d = dict(zip(x, y))
	l = list(d.values())
	print(sum(l))


t = int(input())
for i in range(t):
	l = []
	v = []
	n = int(input())
	for k in range(n):
		l.append(input())
	l.reverse()
	c = 0
	for j in l:
		if j[:-2] not in v:
			v.append(j[:-2])
			if j[-1] == '+':
				c += 1
			else:
				c -= 1
	print(c)


for i in range(int(input())):
	d = {}
	c = 0
	for k in range(int(input())):
		(x, y) = input().split(' ')
		d.update({x: y})
	for value in d.values():
		if value == '+':
			c += 1
		else:
			c -= 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	dic = {}
	for i in range(n):
		(name, vote) = input().split()
		if vote == '+':
			vn = 1
		else:
			vn = -1
		dic.update({name: vn})
	print(sum(dic.values()))