class Solution:
def reverse(self, x):
if x >= 0:
s = str(x)
s = s[::-1]
else:
s = str(-x)
s = s[::-1]
s = '-' + s
s = int(s)
if s > 2**31-1 or s < -2**31:
return 0
return s