Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'. 

Now since chef is not that great in deciphering binary strings, he has decided the following criteria to classify the feedback as Good or Bad : 

If the string contains the substring "010" or "101", then the feedback is Good, else it is Bad. Note that, to be Good it is not necessary to have both of them as substring.

So given some binary strings, you need to output whether according to the chef, the strings are Good or Bad. 

-----Input-----
The first line contains an integer T denoting the number of feedbacks. Each of the next T lines contains a string composed of only '0'  and '1'.

-----Output-----
For every test case, print in a single line Good or Bad as per the Chef's method of classification.

-----Constraints-----
-  1 ≤  T ≤   100 
-  1  ≤  |S|   ≤  105 

Sum of length of all strings in one test file will not exceed 6*106.

-----Example-----
Input:
2
11111110
10101010101010

Output:
Bad
Good

-----Explanation-----
Example case 1.

The string doesn't contain 010 or 101 as substrings.

Example case 2.

The string contains both 010 and 101 as substrings.

Difficulty: EASY
Tags: String algorithms

Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
T = int(input())
for i in range(0, T):
	S = input()
	if '101' in S or '010' in S:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	bstr = input()
	opval = 'Bad'
	for i in range(len(bstr) - 2):
		if bstr[i] == bstr[i + 2] and bstr[i] != bstr[i + 1]:
			opval = 'Good'
			break
	print(opval)


for inputs in range(int(input())):
	code = input()
	if '101' in code or '010' in code:
		print('Good')
	else:
		print('Bad')


t = int(input())
for _ in range(t):
	n = input()
	if '010' in n:
		print('Good')
	elif '101' in n:
		print('Good')
	else:
		print('Bad')


for i in range(int(input())):
	s = input()
	if '101' in s or '010' in s:
		print('Good')
	else:
		print('Bad')


t = int(input())
for i in range(t):
	string = input()
	str1 = '010'
	str2 = '101'
	if str1 in string:
		print('Good')
	elif str2 in string:
		print('Good')
	else:
		print('Bad')


n = int(input())
while n:
	string = input()
	if '101' in string or '010' in string:
		print('Good')
	else:
		print('Bad')
	n -= 1


n = int(input())
for i in range(n):
	s = input()
	is_good = False
	for c in range(1, len(s) - 1):
		target_character = '1' if s[c] == '0' else '0'
		is_good = s[c - 1] == target_character and s[c + 1] == target_character
		if is_good:
			break
	if is_good:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	s = input()
	if '101' in s:
		print('Good')
	elif '010' in s:
		print('Good')
	else:
		print('Bad')


t = int(input())
while t > 0:
	s = input()
	if '010' in s:
		print('Good')
	elif '101' in s:
		print('Good')
	else:
		print('Bad')
	t -= 1


t = int(input())
while t > 0:
	a = input()
	t = t - 1
	if '010' in a or '101' in a:
		print('Good')
	else:
		print('Bad')


t = int(input())
for _ in range(t):
	s = input()
	s1 = ''
	flag = 0
	for i in range(1, len(s) - 1):
		s1 = s[i - 1] + s[i] + s[i + 1]
		if s1 == '101' or s1 == '010':
			flag = 1
			break
	if flag == 1:
		print('Good')
	else:
		print('Bad')


t = int(input())
for i in range(t):
	s = input()
	if '101' in s:
		print('Good')
	elif '010' in s:
		print('Good')
	else:
		print('Bad')


T = int(input())
for i in range(T):
	x = input()
	y1 = x.find('101')
	y2 = x.find('010')
	if y1 == -1 and y2 == -1:
		print('Bad')
	else:
		print('Good')


a = int(input())
for i in range(a):
	b = input()
	if '010' in b or '101' in b:
		print('Good')
	else:
		print('Bad')


t = int(input())
for _ in range(t):
	str_1 = input()
	if '010' in str_1 or '101' in str_1:
		print('Good')
	else:
		print('Bad')


for i in range(int(input())):
	x = input()
	a = x.count('010')
	b = x.count('101')
	if a >= 1 or b >= 1:
		print('Good')
	else:
		print('Bad')


from collections import Counter

def test():
	s = input()
	if '010' in s or '101' in s:
		print('Good')
	else:
		print('Bad')
t = int(input())
for _ in range(t):
	test()


t = int(input())
for i in range(t):
	n = input()
	if '010' in n or '101' in n:
		print('Good')
	else:
		print('Bad')


t = int(input())
for i in range(t):
	s = input()
	a = []
	b = []
	if '101' in s:
		a.append(3)
	elif '010' in s:
		b.append(6)
	else:
		pass
	if len(a) != 0 and len(b) == 0:
		print('Good')
	elif len(a) == 0 and len(b) != 0:
		print('Good')
	else:
		print('Bad')


n = int(input())
for i in range(n):
	good = False
	s = input()
	for j in range(len(s) - 2):
		if s[j:j + 3] == '101' or s[j:j + 3] == '010':
			good = True
			break
	if good:
		print('Good')
	else:
		print('Bad')


t = int(input())
for _ in range(t):
	x = str(input())
	if '010' in x or '101' in x:
		print('Good')
	else:
		print('Bad')


for i in range(int(input())):
	a = input()
	l = len(a)
	for j in range(l - 2):
		if a[j] == '0' and a[j + 1] == '1' and (a[j + 2] == '0'):
			print('Good')
			break
		if a[j] == '1' and a[j + 1] == '0' and (a[j + 2] == '1'):
			print('Good')
			break
	else:
		print('Bad')


for _ in range(int(input())):
	s = input()
	flag = False
	if not s.find('101') == -1:
		flag = True
	elif not s.find('010') == -1:
		flag = True
	if flag:
		print('Good')
	else:
		print('Bad')


n = int(input())
while n > 0:
	s = input()
	if '101' in s or '010' in s:
		print('Good')
	else:
		print('Bad')
	n = n - 1


T = int(input())
for _ in range(T):
	string = input()
	if '101' in string or '010' in string:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	l = input()
	c = 0
	for i in range(0, len(l)):
		s = i
		e = i + 3
		r = l[s:e]
		if r == '101' or r == '010':
			c = 1
			break
	if c == 1:
		print('Good')
	else:
		print('Bad')


t = int(input())
for _ in range(t):
	str = list(input())
	n = len(str)
	c = 0
	for j in range(1, n - 1):
		if str[j - 1] != str[j] != str[j + 1]:
			c = 1
			break
		else:
			c = 0
	if c == 1:
		print('Good')
	else:
		print('Bad')


t = int(input())
for i in range(t):
	s = input()
	fl = -1
	n = len(s)
	for i in range(n - 2):
		if s[i:i + 3] == '010' or s[i:i + 3] == '101':
			fl = 0
			print('Good')
			break
	if fl == -1:
		print('Bad')


T = int(input())
while T > 0:
	T -= 1
	str = input()
	if '010' in str or '101' in str:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	binarystring = input()
	if '101' in binarystring or '010' in binarystring:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	s = input()
	if s.count('101') > 0 or s.count('010') > 0:
		print('Good')
	else:
		print('Bad')


T = int(input())
for p in range(T):
	S = input()
	if '010' in S or '101' in S:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	input_1 = str(input())
	str1 = '010'
	str2 = '101'
	if input_1.find(str1) == -1 and input_1.find(str2) == -1:
		print('Bad')
	else:
		print('Good')


for _ in range(int(input())):
	n = input()
	good = ['010', '101']
	t = False
	for x in good:
		if x in n:
			print('Good')
			t = True
			break
	if not t:
		print('Bad')


test = int(input())
while test > 0:
	st = input()
	test = test - 1
	if '101' in st:
		print('Good')
	elif '010' in st:
		print('Good')
	else:
		print('Bad')


T = int(input())
for i in range(T):
	S = input()
	if '101' in S:
		print('Good')
	elif '010' in S:
		print('Good')
	else:
		print('Bad')


v = int(input())
for _ in range(v):
	str = list(input())
	m = len(str)
	c = 0
	for j in range(1, m - 1):
		if str[j - 1] != str[j] != str[j + 1]:
			c = 1
			break
		else:
			c = 0
	if c == 1:
		print('Good')
	else:
		print('Bad')


n = int(input())
for i in range(1, n + 1):
	a = input()
	if '010' in a or '101' in a:
		print('Good')
	else:
		print('Bad')


t = int(input())
ls = ['101', '010']
for i in range(t):
	s = input()
	for l in ls:
		if l in s:
			print('Good')
			break
	else:
		print('Bad')


t = int(input())
r = 0
good = ['010', '101']
if 1 <= t <= 100:
	for i in range(t):
		s = str(input())
		if 1 <= len(s) <= 10 ** 5:
			for x in range(len(s) - 2):
				if s[x:x + 3] in good:
					r = r + 1
		if r > 0:
			print('Good')
		else:
			print('Bad')
		r = 0


import re
for i in range(int(input())):
	s = input()
	if s.__contains__('010'):
		print('Good')
	elif s.__contains__('101'):
		print('Good')
	else:
		print('Bad')


inps = int(input())
inputs = []
for i in range(inps):
	inputs.append(input())
for i in inputs:
	good = False
	for j in range(2, len(i)):
		if i[j - 2:j + 1] == '010' or i[j - 2:j + 1] == '101':
			good = True
			break
	if good:
		print('Good')
	else:
		print('Bad')


tc = int(input())
for i in range(tc):
	s = input()
	lst = []
	cnt = 0
	cnt1 = 0
	for i in range(len(s)):
		lst.append(s[i:i + 3])
	for i in range(len(lst)):
		if lst[i] == '010':
			cnt += 1
		elif lst[i] == '101':
			cnt1 += 1
	if cnt > 0 or cnt1 > 0:
		print('Good')
	else:
		print('Bad')


for i in range(int(input())):
	s = input()
	flag = 0
	if '010' in s or '101' in s:
		flag = 1
	if flag == 1:
		print('Good')
	else:
		print('Bad')


for i in range(int(input())):
	s = input()
	p = 'Bad'
	for i in range(len(s) - 2):
		if '0' in s[i] and '1' in s[i + 1] and ('0' in s[i + 2]):
			p = 'Good'
		if '1' in s[i] and '0' in s[i + 1] and ('1' in s[i + 2]):
			p = 'Good'
	print(p)


for _ in range(int(input())):
	n = list(input())
	l = len(n)
	for i in range(1, l - 1):
		if n[i - 1] != n[i] != n[i + 1]:
			print('Good')
			break
	else:
		print('Bad')


t = int(input())
while t > 0:
	s = input()
	n = len(s)
	c = s.find('101', 0, n) + s.find('010', 0, n)
	if c == -2:
		print('Bad')
	else:
		print('Good')
	t = t - 1


t = int(input())
for i in range(t):
	s = input()
	ans = False
	for j in range(len(s) - 2):
		if s[j] == '0':
			if s[j + 1] == '1':
				if s[j + 2] == '0':
					ans = True
					break
		elif s[j + 1] == '0':
			if s[j + 2] == '1':
				ans = True
				break
	if ans:
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	ab = ['101', '010']
	a = str(input())
	for check in ab:
		if check in a:
			print('Good')
			break
	else:
		print('Bad')


for i in range(int(input())):
	x = input()
	d = {x[i:i + 3]: 1 for i in range(0, len(x) - 2)}
	if d.get('101') or d.get('010'):
		print('Good')
	else:
		print('Bad')


for _ in range(int(input())):
	i = '101'
	j = '010'
	n = input()
	if i in n or j in n:
		print('Good')
	else:
		print('Bad')


for i in range(int(input().strip())):
	binst = input()
	result = 'Bad'
	for i in range(len(binst) - 2):
		st = binst[i:i + 3]
		if st == '101' or st == '010':
			result = 'Good'
			break
	print(result)


t = int(input())
str1 = '010'
str2 = '101'
list1 = []
for i in range(0, t):
	str3 = str(input())
	if str1 in str3 and str2 not in str3 or (str2 in str3 and str1 not in str3) or (str1 in str3 and str2 in str3):
		list1.append('Good')
	else:
		list1.append('Bad')
for j in list1:
	print(j)


T = int(input())
for _ in range(T):
	S = str(input())
	if '010' in S or '101' in S:
		print('Good')
	else:
		print('Bad')


t = int(input())
for i in range(t):
	x = list(input())
	y = len(x)
	flag = False
	for i in range(1, y - 1):
		if x[i - 1] != x[i] != x[i + 1]:
			print('Good')
			break
	else:
		print('Bad')


t = int(input())
for i in range(t):
	m = input()
	f = 0
	for i in range(len(m) - 2):
		if m[i] == m[i + 2] and m[i] != m[i + 1]:
			f = 1
			break
	if f == 1:
		print('Good')
	else:
		print('Bad')