n = int(input())
total = 0
for i in range(n):
j = input()
number = int(j[:-1])
power = int(j[-1])
total = total + number**power
print(total)