const readline = require('readline') const rl = readline.createInterface({ input: process.stdin, ouput: process.stdout }) rl.on('line', line=>{ let inArr = line.trim().split(' ') let s = inArr[0].split('') let stack = [] let flag = 1 for (let i = 0; i < s.length; i++) { if(s[i] == '[' || s[i] == '('){ stack.push(s[i]) }else if(s[i] == ']' || s[i] == ')'){ if(stack.length === 0){ flag = 0 break } let c = stack[stack.length -1] stack.pop() if((c == '[' && s[i] != ']') || ( c == '(' && s[i] != ')' )){ flag = 0 break } } } if(stack.length !== 0){ flag = 0 } console.log(flag? 'true' : 'false') })