class Solution:

    def reverse(self, x: int) ->int:
        if x < 0:
            sign = -1
        else:
            sign = 1
        x *= sign
        li = list(str(x))
        li.reverse()
        num = 0
        for digit in li:
            num = num * 10 + int(digit)
        answer = num * sign
        if answer < pow(-2, 31) or answer > pow(2, 31) - 1:
            return 0
        else:
            return answer


s = Solution()
x = 123
print(s.reverse(x))

51700a43d14dcaf46f3f5c4445ee7a1ef9b127de
class Solution:
    <mask token>


<mask token>

class Solution:

    def reverse(self, x: int) ->int:
        if x < 0:
            sign = -1
        else:
            sign = 1
        x *= sign
        li = list(str(x))
        li.reverse()
        num = 0
        for digit in li:
            num = num * 10 + int(digit)
        answer = num * sign
        if answer < pow(-2, 31) or answer > pow(2, 31) - 1:
            return 0
        else:
            return answer


<mask token>

class Solution:

    def reverse(self, x: int) ->int:
        if x < 0:
            sign = -1
        else:
            sign = 1
        x *= sign
        li = list(str(x))
        li.reverse()
        num = 0
        for digit in li:
            num = num * 10 + int(digit)
        answer = num * sign
        if answer < pow(-2, 31) or answer > pow(2, 31) - 1:
            return 0
        else:
            return answer


<mask token>
print(s.reverse(x))

class Solution:

    def reverse(self, x: int) ->int:
        if x < 0:
            sign = -1
        else:
            sign = 1
        x *= sign
        li = list(str(x))
        li.reverse()
        num = 0
        for digit in li:
            num = num * 10 + int(digit)
        answer = num * sign
        if answer < pow(-2, 31) or answer > pow(2, 31) - 1:
            return 0
        else:
            return answer


s = Solution()
x = 123
print(s.reverse(x))
