You are given a string $\mbox{S}$. 

Your task is to find out whether $\mbox{S}$ is a valid regex or not.

Input Format

The first line contains integer $\mathbf{T}$, the number of test cases. 

The next $\mathbf{T}$ lines contains the string $\mbox{S}$.

Constraints

$\textbf{0}<T<100$

Output Format

Print "True" or "False" for each test case without quotes.

Sample Input
2
.*\+
.*+

Sample Output
True
False

Explanation

.*\+ : Valid regex. 

.*+: Has the error multiple repeat. Hence, it is invalid.

Difficulty: EASY

Starter code:

Solutions:
import re
for i in range(int(input())):
	try:
		re.compile(input().rstrip())
		print(True)
	except re.error as e:
		print(False)


import re
for _ in range(int(input())):
	try:
		re.compile(input())
		print('True')
	except re.error:
		print('False')


import re
import sys
T = int(sys.stdin.readline())
for _ in range(T):
	S = sys.stdin.readline().strip()
	try:
		re.compile(S)
		print(True)
	except Exception as e:
		print(False)


import re
try:
	t_number = int(input())
except ValueError as e:
	print('Error Code:', e)
for _ in range(t_number):
	try:
		re.compile(input().strip())
		print('True')
	except:
		print('False')


import re
for _ in range(int(input().strip())):
	try:
		re.compile(input().strip())
		print(True)
	except:
		print(False)


import re
t = int(input().strip())
for i in range(t):
	a = input().strip()
	try:
		b = re.compile(a)
		print('True')
	except:
		print('False')


import re
for i in range(int(input())):
	try:
		re.compile(input())
		is_valid = True
	except re.error:
		is_valid = False
	print(is_valid)


import re
tests = int(input(''))
for dummy in range(tests):
	inp = input('')
	try:
		re.search(inp, 'test_string')
		print(True)
	except:
		print(False)


import re
for _ in range(int(input())):
	try:
		re.compile(input())
	except:
		print(False)
	else:
		print(True)


import re
times = int(input())
for index in range(times):
	try:
		re.compile(input())
		print('True')
	except re.error:
		print('False')


import re
N = int(input())
for _ in range(N):
	try:
		re.compile(input())
		is_valid = True
	except re.error:
		is_valid = False
	print(is_valid)


import re
for i in range(int(input())):
	try:
		re.compile(input())
		print('True')
	except:
		print('False')


import re
N = int(input())
for _ in range(N):
	try:
		re.compile(input())
		print(True)
	except re.error:
		print(False)


import re
for _ in range(int(input())):
	try:
		re.compile(input())
	except re.error:
		print(False)
	else:
		print(True)


import re
T = int(input())
for i in range(T):
	regex = input().strip()
	try:
		re.compile(regex)
		print('True')
	except:
		print('False')


from re import *
for _ in range(int(input())):
	try:
		compile(input())
		print('True')
	except Exception:
		print('False')


import re
T = int(input())
for i in range(T):
	try:
		re.compile(input())
	except Exception:
		print('False')
	else:
		print('True')


import re
n = int(input().strip())
for i in range(n):
	try:
		re.compile(input().strip())
		print('True')
	except:
		print('False')


from re import compile
for i in range(int(input())):
	try:
		compile(input())
	except:
		print('False')
	else:
		print('True')


import re
a = int(input())
for i in range(0, a):
	try:
		b = input()
		re.compile(b)
		print('True')
	except:
		print('False')
		continue


import re
n = int(input())
for i in range(n):
	s = input()
	try:
		re.compile(s)
		print(True)
	except Exception as e:
		print(False)


import re
for i in range(int(input())):
	try:
		s = input()
		re.compile(s)
	except:
		print(False)
		continue
	print(True)


import re
N = int(input())
for one in range(N):
	try:
		re.compile(input())
		print(True)
	except:
		print(False)


from re import compile
for _ in range(int(input())):
	try:
		compile(input().strip())
		print(True)
	except Exception as e:
		print(False)


import re
t = int(input())
for each in range(t):
	try:
		re.compile(input().strip())
		print(True)
	except:
		print(False)


from re import compile
cases = int(input())
for _ in range(0, cases):
	expression = input()
	try:
		compile(expression)
		print('True')
	except:
		print('False')


import re
n_tests = int(input())
for _ in range(n_tests):
	try:
		re.compile(input())
		print(True)
	except:
		print(False)


import re
n = int(input())
for i in range(n):
	p = True
	try:
		r = re.compile(input())
	except:
		p = False
	print(p)


import re
import sre_constants
n = int(input())
for _ in range(n):
	try:
		re.search(input(), 'a')
		print(True)
	except sre_constants.error:
		print(False)


import re
for _ in range(int(input())):
	try:
		s = re.compile(input())
		isValid = True
	except re.error:
		isValid = False
	print(isValid)


import re
n = int(input())
for i in range(n):
	s = input()
	try:
		re.compile(s)
		print('True')
	except re.error:
		print('False')


import re
n = int(input())
s = 'hello world'
for _ in range(n):
	test_regex = input()
	try:
		re.findall(test_regex, s)
		print('True')
	except:
		print('False')


import re
N = int(input())
for _ in range(N):
	try:
		re.compile(input())
		print(True)
	except Exception as e:
		print(False)


import re
t = int(input())
while t > 0:
	t = t - 1
	try:
		m = re.compile(input())
		print('True')
	except re.error as e:
		print('False')


import re
for _ in range(int(input())):
	try:
		re.compile(input())
		is_valid = True
	except re.error:
		is_valid = False
	print(is_valid)


import re
N = int(input())
for i in range(N):
	try:
		curRE = re.compile(input())
		print('True')
	except:
		print('False')


import re

def __starting_point():
	t = int(input().strip())
	for _ in range(t):
		try:
			re.compile(input().strip())
			res = True
		except BaseException:
			res = False
		print(res)
__starting_point()


import re
for _ in range(int(input())):
	try:
		re.compile(input())
	except Exception:
		print(False)
	else:
		print(True)


import re
for test in range(int(input())):
	try:
		print(bool(re.compile(input())))
	except re.error:
		print(False)


import re
T = int(input())
for i in range(T):
	try:
		re.match(input(), '')
		print('True')
	except:
		print('False')


import re
for i in range(int(input())):
	try:
		s = input()
		re.compile(s)
	except:
		print('False')
	else:
		print('True')


import re
for _ in range(int(input())):
	try:
		re.compile(input())
		print(True)
	except Exception:
		print(False)


import re
n = int(input())
for i in range(0, n):
	try:
		s = input()
		re.compile(s)
		print('True')
	except re.error:
		print('False')


import re
n = int(input())
for i in range(n):
	s = input()
	try:
		re.compile(s)
		is_valid = True
	except re.error:
		is_valid = False
	print(is_valid)


import re
for _ in range(int(input())):
	reg = input()
	try:
		m = re.match(reg, 'test')
		print('True')
	except re.error:
		print('False')


import re

def solve():
	s = input()
	try:
		re.compile(s)
		print('True')
	except Exception as e:
		print('False')

def main():
	n = int(input())
	for _ in range(n):
		solve()
main()


import re
for _ in range(int(input())):
	val = True
	try:
		re.compile(input())
	except:
		val = False
	print(val)


import re
for i in range(int(input())):
	s = input()
	try:
		match = re.compile(s)
		print('True')
	except:
		print('False')


import re
l = int(input())
for i in range(l):
	reg = input()
	try:
		re.match(reg, '')
		print(True)
	except re.error:
		print(False)


import re
result = []
for i in range(int(input())):
	try:
		s = input()
		re.compile(s)
		result.append(True)
	except:
		result.append(False)
for x in result:
	print(x)


import re
for _ in range(int(input())):
	pattern = input()
	compiled = True
	try:
		exp = re.compile(pattern)
	except re.error:
		compiled = False
	print(compiled)


import re
for _ in range(int(input())):
	s = input()
	ok = False
	try:
		re.compile(s)
		ok = True
	except:
		pass
	print(ok)


import re
for _ in range(int(input())):
	try:
		re.compile(input())
		print(True)
	except:
		print(False)


import re
for _ in range(int(input())):
	try:
		re.search(input(), '')
		print('True')
	except re.error:
		print('False')


import re
for _ in range(int(input())):
	try:
		pattern = re.compile(input())
		print(True)
	except:
		print(False)


import re
for i in range(int(input())):
	f = 0
	p = input()
	try:
		re.compile('' + p)
	except:
		f = 1
	if f == 0:
		print('True')
	else:
		print('False')


from re import compile
for _ in range(int(input())):
	try:
		compile(input())
		print(True)
	except Exception:
		print(False)


import re
n = int(input())
for _ in range(n):
	try:
		re.compile(input())
		print(True)
	except Exception:
		print(False)


from re import compile
n = int(input())
for _ in range(n):
	try:
		compile(input())
		print('True')
	except:
		print('False')


import re
for i in range(int(input())):
	try:
		s = input()
		re.compile(s)
		print('True')
	except:
		print('False')


import re
for k in range(int(input())):
	try:
		re.compile(input())
		print('True')
	except re.error as e:
		print('False')


import re

def is_regex_valid(s):
	try:
		re.compile(s)
	except re.error:
		return False
	return True
n = int(input())
for _ in range(n):
	r = input()
	print(is_regex_valid(r))


import re
import sys
for i in range(int(input())):
	try:
		re.compile(input())
		print('True')
	except:
		print('False')


import re
for i in range(int(input())):
	try:
		re.compile(input())
		print(True)
	except re.error:
		print(False)


import re
for _ in range(int(input())):
	try:
		re.compile(input().strip())
		print('True')
	except:
		print('False')


import re
for _ in range(int(input())):
	x = input()
	try:
		re.compile(x)
		print('True')
	except:
		print('False')


import re
for _ in range(int(input())):
	ss = input()
	try:
		re.compile(ss)
	except re.error as e:
		print(False)
	else:
		print(True)


import re
n = int(input())
for _ in range(n):
	reg = input()
	try:
		re.compile(reg)
	except:
		print(False)
		continue
	print(True)


import re
n = int(input())
for i in range(n):
	try:
		p = re.compile(input())
		print(True)
	except:
		print(False)


import re
n = int(input())
for i in range(n):
	try:
		r = re.compile(input())
		print(True)
	except re.error as e:
		print(False)


import sys
import re
dontneed = int(input())
data = sys.stdin.readlines()
for i in ["r'" + i + "'" for i in data]:
	try:
		testregexresult = re.search(i, 'teststringlol')
	except Exception as E:
		print('False')
	else:
		print('True')


import re
T = int(input())
for _ in range(T):
	try:
		re.compile(input())
		print(True)
	except:
		print(False)


import re
for _ in range(int(input())):
	try:
		re.compile(input())
		print(True)
	except re.error:
		print(False)


import re
for i in range(int(input())):
	try:
		s = str(input())
		re.compile(s)
		print(True)
	except:
		print(False)


import re
for test in range(int(input())):
	try:
		re.match(input(), '')
		print('True')
	except:
		print('False')


import re
t = int(input())
for _ in range(t):
	try:
		re.compile(input())
		print(True)
	except re.error:
		print(False)


from re import *
N = int(input())
for i in range(N):
	try:
		pattern = input()
		prog = compile(pattern)
		print(True)
	except error:
		print(False)


import re
lines = int(input())
for _ in range(lines):
	try:
		re.compile(input())
	except:
		print(False)
	else:
		print(True)


import re
for _ in range(int(input())):
	try:
		rg = re.compile(input())
		res = rg.search('\t abcdefghijklmnopqrstuvwxyz0123456789,\\.\\*\\-\\+\\?\n')
		print('True')
	except:
		print('False')


import re
a = int(input())
for i in range(0, a):
	regex = input()
	b = 'test string'
	try:
		bool(re.search(regex, b))
		print('True')
	except:
		print('False')


import re
for _ in range(int(input())):
	ans = True
	try:
		reg = re.compile(input())
	except re.error:
		ans = False
	print(ans)


import re
for i in range(int(input())):
	try:
		re.compile(input())
		print(True)
	except Exception as ex:
		print(False)


import re
for _ in range(int(input())):
	s = input()
	try:
		s = re.compile(s)
		print('True')
	except:
		print('False')


import re
n = int(input())
for i in range(0, n):
	regex = input()
	try:
		re.match(regex, 'hello')
		print('True')
	except Exception as e:
		print('False')


import re, sys
for i in range(int(input())):
	try:
		regex = input()
		ans = re.search(regex, '')
	except ZeroDivisionError as e:
		print('Error Code: integer division or modulo by zero')
	except ValueError as v:
		print('Error Code: {}'.format(v))
	except:
		print('False')
	else:
		print('True')


import re
num = int(input())
for i in range(0, num):
	list = str(input())
	try:
		m = re.search(list, 'abcdef')
		print('True')
	except Exception as e:
		print('False')


import re
t = int(input())
for _ in range(t):
	s = input()
	try:
		re.compile(s)
		print(True)
	except:
		print(False)


import re
T = int(input())
for i in range(T):
	try:
		re.compile(input())
		print(1 == 1)
	except:
		print(1 == 0)