Given the menu of the two restaurants. There may be a chance of fight between them if any one of them have any item in common and you surely don't want that to happen. Each of the menu has 5 items (strings) in them. So, your task is to find out if there is any need to change the menu or let them be happy with their respective menu.
 
Example 1:
Input:
cake pastry fish candy meat
burger ham fish cake sauce
Output:
CHANGE
Explanation:
"fish" is common in both the menu.
Example 2:
Input:
pizza chicken cake chilli candy
choco coco cabbage panner cheese
Output:
BEHAPPY
Expanation:
No item is common.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function is_common() which takes first menu as first parameter and second menu as second parameter and returns the string "CHANGE" if any item is common otherwise returns "BEHAPPY"(Without quotes).
 
Expected Time Complexity:   O(n)
Expected Space Complexity: O(n)
 
Constraints:
1 <= Size of each string <= 1000

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3





class Solution:

    def is_common(self, s, t):

        # Code here

Solutions:
class Solution:

	def is_common(self, s, t):
		for i in s:
			if i in t:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		st = set()
		for i in s:
			st.add(i)
		for i in t:
			if i in s:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		counter = 0
		for i in range(len(s)):
			if s[i] in t:
				counter = 1
				break
			else:
				pass
		if counter == 1:
			return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		c = 0
		for i in s:
			for j in t:
				if i == j:
					c += 1
		if c == 0:
			return 'BEHAPPY'
		else:
			return 'CHANGE'


class Solution:

	def is_common(self, s, t):
		s = set(s)
		t = set(t)
		comm = s & t
		if len(comm) == 0:
			return 'BEHAPPY'
		else:
			return 'CHANGE'


class Solution:

	def is_common(self, s, t):
		a = 0
		for i in range(len(s)):
			if s[i] in t:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		for i in range(len(s)):
			if s[i] in t:
				return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		items1 = set(s)
		items2 = set(t)
		for item in items1:
			if item in items2:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		n = []
		for x in s:
			if x in t:
				n.append(x)
		for y in t:
			if y in s:
				n.append(y)
		if n:
			return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		r = set(s) & set(t)
		if len(r) >= 1:
			return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		common = []
		for item in t[0:]:
			if item in s:
				common.append(item)
		if len(common) > 0:
			return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		return 'CHANGE' if set(s).intersection(set(t)) else 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		for c in s:
			for d in t:
				if c == d:
					return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		dic = {}
		for i in s:
			dic[i] = 0
		for i in t:
			if dic.get(i) is None:
				continue
			if dic[i] == 0:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		var = 0
		for i in s:
			if i not in t:
				var = 1
				continue
			else:
				return 'CHANGE'
				break
		if var == 1:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		for x in s:
			if x in t:
				return 'CHANGE'
				break
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		f = set(s)
		g = set(t)
		i = f.intersection(g)
		k = 'CHANGE'
		l = 'BEHAPPY'
		if len(i) == 0:
			return l
		else:
			return k


class Solution:

	def is_common(self, s, t):
		lisA = list(s)
		lisB = list(t)
		if len(set(lisA) & set(lisB)) > 0:
			return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		res = []
		for i in s:
			if i in t:
				res.append(i)
		if len(res) > 0:
			return 'CHANGE'
		else:
			return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		s = set(s)
		t = set(t)
		ans = s.intersection(t)
		if len(ans) == 0:
			return 'BEHAPPY'
		else:
			return 'CHANGE'


class Solution:

	def is_common(self, s, t):
		l = list(s)
		w = list(t)
		for i in l:
			if i in w:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		set_a = set(s)
		set_t = set(t)
		if set_a & set_t == set():
			return 'BEHAPPY'
		else:
			return 'CHANGE'


class Solution:

	def is_common(self, s, t):
		for i in s:
			if i in t:
				return 'CHANGE'
		return 'behappy'.upper()


class Solution:

	def is_common(self, s, t):
		flag = 0
		for ch in s:
			if ch in t:
				flag = 1
				break
		if flag == 1:
			return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		p = set(s)
		r = set(t)
		if p.isdisjoint(r):
			return 'BEHAPPY'
		else:
			return 'CHANGE'


class Solution:

	def is_common(self, a, b):
		for i in a:
			if i in b:
				return 'CHANGE'
		return 'BEHAPPY'


class Solution:

	def is_common(self, s, t):
		s = set(s)
		for i in t:
			if i in s:
				return 'CHANGE'
		return 'BEHAPPY'
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		s = list(input().split())
		t = list(input().split())
		ob = Solution()
		ans = ob.is_common(s, t)
		print(ans)


class Solution:

	def is_common(self, s, t):
		a = 'CHANGE'
		b = 'BEHAPPY'
		for i in s:
			c = 0
			for j in t:
				if i == j:
					c = c + 1
					break
			if c > 0:
				return a
		return b
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		s = list(input().split())
		t = list(input().split())
		ob = Solution()
		ans = ob.is_common(s, t)
		print(ans)


class Solution:

	def is_common(self, s, t):
		s1 = set(s)
		t1 = set(t)
		ls = list(s1 & t1)
		if len(ls) > 0:
			return 'CHANGE'
		else:
			return 'BEHAPPY'
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		s = list(input().split())
		t = list(input().split())
		ob = Solution()
		ans = ob.is_common(s, t)
		print(ans)


class Solution:

	def is_common(self, s, t):
		a = 0
		for i in range(len(s)):
			if s[i] in t:
				a = 1
		if a == 1:
			return 'CHANGE'
		return 'BEHAPPY'
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		s = list(input().split())
		t = list(input().split())
		ob = Solution()
		ans = ob.is_common(s, t)
		print(ans)


class Solution:

	def is_common(self, s, t):
		flag = 0
		x = str(s).split()
		y = str(t).split()
		for i in s:
			if i in t:
				return 'CHANGE'
				flag += 1
		if flag == 0:
			return 'BEHAPPY'