class Solution:
def isValid(self, s: str) -> bool:
if len(s) & 1: return False
stk = []
book = {'(': ')', '[': ']', '{': '}'}
for c in s:
if c in book:
stk.append(book[c])
else:
if not stk or stk[-1] != c:
return False
stk.pop()
return False if stk else True