class Solution:
    def isValid(self , s: str) -> bool:
        if not s: return False
        if len(s)%2!=0: return False
        match,mark={')':'(',']':'[','}':'{'},[]
        for item in s:
            if item in ['(','[','{']:
                mark.append(item)
            elif item in [')',']','}']:
                if not mark: return False
                if mark[-1]==match[item]:
                    mark.pop()
            else: return False
        return not mark