total = 0

for i in xrange(1, 1001):
  total += i ** i

print total % (10 ** 10)