class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        p=abs(x)
        rev=int(str(p)[::-1])
        if(x<0):
            if((-rev)<pow(-2,31)):
                return 0
            else:
                return -(rev)
        else:
            if(rev>(pow(2,31)-1)):
                return 0
            else:
                return rev