from itertools import*a='()[]{}<>'all(any(c[-1]!=d[0]for c,d in zip(q,q[1:]))or print(''.join(q))for p in permutations(open(0))for q in product(*[(c[:-1],a[a.find(c[-2])^1]+c[-3:0:-1]+a[a.find(c[0])^1])for c in p]))
[-----> )------------[ {--< }---)
<-----]]------------((---{{--<
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!