Given a sequence of moves for a robot. Check if the sequence is circular or not. 
A sequence of moves is circular if the first and last positions of the robot are the same. A move can be one of the following :
    G - Go one unit
    L - Turn left
    R - Turn right
Example 1:
Input: path = "GLGLGLG"
Output: "Circular"
Explanation: If we start form 
(0,0) in a plane then we will 
back to (0,0) by the end of the 
sequence.
Ã¢â¬â¹Example 2:
Input: path = "GGGGL"
Output: "Not Circular"
Explanation: We can't return to 
same place at the end of the path.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function isCircular() which takes the string path as input and returns "Circular" if the path is circular else returns "Not Circular".
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ |S| ≤ 10^{5}

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:

    def isCircular(self, path):
        # code here

Solutions:
class Solution:

	def isCircular(self, path):
		i = j = 0
		pre = 'r'
		for k in path:
			if k == 'G':
				if pre == 'r':
					j += 1
				elif pre == 'l':
					j -= 1
				elif pre == 'u':
					i -= 1
				elif pre == 'd':
					i += 1
			elif k == 'L':
				if pre == 'r':
					pre = 'u'
				elif pre == 'l':
					pre = 'd'
				elif pre == 'u':
					pre = 'l'
				elif pre == 'd':
					pre = 'r'
			elif k == 'R':
				if pre == 'r':
					pre = 'd'
				elif pre == 'l':
					pre = 'u'
				elif pre == 'u':
					pre = 'r'
				elif pre == 'd':
					pre = 'l'
		if i == 0 and j == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		l = [0, 0]
		dir = 1
		for i in range(len(path)):
			if path[i] == 'G':
				if dir == 1:
					l[0] += 1
				elif dir == 2:
					l[1] += 1
				elif dir == 3:
					l[0] -= 1
				else:
					l[1] -= 1
			elif path[i] == 'L':
				dir += 1
				if dir > 4:
					dir = 1
			else:
				dir -= 1
				if dir == 0:
					dir = 4
		if l == [0, 0]:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		direction = 0
		x = 0
		y = 0
		for i in path:
			if i == 'G':
				if direction == 0:
					y += 1
				elif direction == 1:
					x += 1
				elif direction == 2:
					y -= 1
				elif direction == 3:
					x -= 1
			elif i == 'L':
				if direction == 0:
					direction = 3
				else:
					direction -= 1
			elif i == 'R':
				if direction == 3:
					direction = 0
				else:
					direction += 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, moves):
		(x, y) = (0, 0)
		direction = 'N'
		for move in moves:
			if move == 'G':
				if direction == 'N':
					y += 1
				elif direction == 'S':
					y -= 1
				elif direction == 'E':
					x += 1
				elif direction == 'W':
					x -= 1
			elif move == 'L':
				if direction == 'N':
					direction = 'W'
				elif direction == 'S':
					direction = 'E'
				elif direction == 'E':
					direction = 'N'
				elif direction == 'W':
					direction = 'S'
			elif move == 'R':
				if direction == 'N':
					direction = 'E'
				elif direction == 'S':
					direction = 'W'
				elif direction == 'E':
					direction = 'S'
				elif direction == 'W':
					direction = 'N'
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		angle = 0
		for i in path:
			if i == 'G':
				if angle % 360 == 0:
					x += 1
				elif angle % 360 == 180:
					x -= 1
				elif angle % 360 == 90:
					y += 1
				else:
					y -= 1
			elif i == 'R':
				angle += 90
			elif i == 'L':
				angle += 270
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		dir = 'N'
		y = 0
		x = 0
		for i in path:
			if dir == 'N' and i == 'G':
				y = y + 1
			elif dir == 'E' and i == 'G':
				x = x + 1
			elif dir == 'S' and i == 'G':
				y = y - 1
			elif dir == 'W' and i == 'G':
				x = x - 1
			if dir == 'N' and i == 'L':
				dir = 'W'
			elif dir == 'N' and i == 'R':
				dir = 'E'
			elif dir == 'W' and i == 'L':
				dir = 'S'
			elif dir == 'W' and i == 'R':
				dir = 'N'
			elif dir == 'S' and i == 'L':
				dir = 'E'
			elif dir == 'S' and i == 'R':
				dir = 'W'
			elif dir == 'E' and i == 'L':
				dir = 'N'
			elif dir == 'E' and i == 'R':
				dir = 'S'
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		dir = 0
		xn = 0
		yn = 0
		for i in range(len(path)):
			move = path[i]
			if move == 'R':
				dir = (dir + 1) % 4
			elif move == 'L':
				dir = (4 + dir - 1) % 4
			elif dir == 0:
				yn = yn + 1
			elif dir == 1:
				xn = xn + 1
			elif dir == 2:
				yn = yn - 1
			else:
				xn = xn - 1
		if xn == 0 and yn == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		d = {0: [1, 0], 1: [0, 1], 2: [-1, 0], 3: [0, -1]}
		position = [0, 0]
		direction = 0
		for item in path:
			if item == 'G':
				position[0] += d[direction][0]
				position[1] += d[direction][1]
			if item == 'L':
				direction = (direction - 1) % 4
			if item == 'R':
				direction = (direction + 1) % 4
		return 'Circular' if position == [0, 0] else 'Not Circular'


class Solution:

	def isCircular(self, path):
		(i, j) = (0, 0)
		d = 0
		for x in path:
			if x == 'G':
				if d % 2 == 0:
					i = i - 1 if d == 2 else i + 1
				else:
					j = j + 1 if d == 1 else j - 1
			elif x == 'L':
				d = (d + 1) % 4
			else:
				d = d - 1 if d != 0 else 3
		if i == 0 and j == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x_axis = 0
		y_axis = 0
		direction = 0
		for char in path:
			if char == 'L':
				direction += 1
			elif char == 'R':
				direction -= 1
			elif char == 'G':
				if direction % 4 == 1:
					x_axis += 1
				elif direction % 4 == 2:
					y_axis -= 1
				elif direction % 4 == 3:
					x_axis -= 1
				elif direction % 4 == 0:
					y_axis += 1
		if x_axis == 0 and y_axis == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		dir = [(1, 0), (0, 1), (-1, 0), (0, -1)]
		cur = 0
		for i in path:
			if i == 'G':
				(movex, movey) = dir[cur]
				x += movex
				y += movey
			elif i == 'L':
				if cur == 0:
					cur = 3
				else:
					cur -= 1
			elif cur == 3:
				cur = 0
			else:
				cur += 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		direc = ['left', 'up', 'right', 'down']
		index = 1
		start = [1, 1]
		for i in path:
			if i == 'G':
				if direc[index] == 'up':
					start[1] += 1
				elif direc[index] == 'down':
					start[1] -= 1
				elif direc[index] == 'left':
					start[0] -= 1
				else:
					start[0] += 1
			elif i == 'L':
				index -= 1
				index %= 4
			else:
				index += 1
				index %= 4
		return 'Circular' if start[0] == 1 and start[1] == 1 else 'Not Circular'


class Solution:

	def isCircular(self, path):
		N = 1
		S = 2
		E = 3
		W = 4
		curr = 1
		x = 0
		y = 0
		for i in path:
			if i == 'G':
				if curr == 1:
					y += 1
				elif curr == 2:
					y -= 1
				elif curr == 3:
					x += 1
				else:
					x -= 1
			elif i == 'L':
				if curr == N:
					curr = W
				elif curr == S:
					curr = E
				elif curr == E:
					curr = N
				elif curr == W:
					curr = S
			elif i == 'R':
				if curr == N:
					curr = E
				elif curr == S:
					curr = W
				elif curr == E:
					curr = S
				elif curr == W:
					curr = N
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(x, y) = (0, 0)
		(dirX, dirY) = (0, 1)
		for p in path:
			if p == 'G':
				(x, y) = (x + dirX, y + dirY)
			elif p == 'L':
				(dirX, dirY) = (-1 * dirY, dirX)
			else:
				(dirX, dirY) = (dirY, -1 * dirX)
		if (x, y) == (0, 0):
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		i = 0
		j = 0
		dir = 'E'
		LL = ['E', 'S', 'W', 'N']
		for c in path:
			if c == 'G':
				j += (dir == 'N') - (dir == 'S')
				i += (dir == 'E') - (dir == 'W')
			if c == 'R':
				dir = LL[(LL.index(dir) + 1) % 4]
			if c == 'L':
				dir = LL[(LL.index(dir) - 1) % 4]
		return 'Circular' if i == 0 and j == 0 else 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		dirc = 'R'
		for i in path:
			if i == 'G':
				if dirc == 'R':
					x += 1
				elif dirc == 'U':
					y += 1
				elif dirc == 'L':
					x -= 1
				elif dirc == 'D':
					y -= 1
			elif i == 'L':
				if dirc == 'R':
					dirc = 'U'
				elif dirc == 'U':
					dirc = 'L'
				elif dirc == 'L':
					dirc = 'D'
				elif dirc == 'D':
					dirc = 'R'
			elif i == 'R':
				if dirc == 'R':
					dirc = 'D'
				elif dirc == 'U':
					dirc = 'R'
				elif dirc == 'L':
					dirc = 'U'
				elif dirc == 'D':
					dirc = 'L'
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		position = [0, 0]
		directions = ((0, 1), (1, 0), (0, -1), (-1, 0))
		dir_idx = 0
		for a in path:
			if a == 'G':
				position[0] += directions[dir_idx][0]
				position[1] += directions[dir_idx][1]
			elif a == 'L':
				dir_idx = (dir_idx - 1) % 4
			elif a == 'R':
				dir_idx = (dir_idx + 1) % 4
		if position[0] == 0 and position[1] == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)]
		curr = 0
		(posx, posy) = (0, 0)
		for char in path:
			if char == 'G':
				posx += dirs[curr][0]
				posy += dirs[curr][1]
			elif char == 'L':
				curr -= 1
				if curr == -1:
					curr = 3
			else:
				curr += 1
				if curr == 4:
					curr = 0
		if posx == 0 and posy == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		position = (0, 0)
		current_orientation = 'u'
		for move in path:
			if move == 'G':
				if current_orientation == 'u':
					position = (position[0], position[1] + 1)
				elif current_orientation == 'l':
					position = (position[0] - 1, position[1])
				elif current_orientation == 'r':
					position = (position[0] + 1, position[1])
				elif current_orientation == 'd':
					position = (position[0], position[1] - 1)
			if move == 'L':
				if current_orientation == 'u':
					current_orientation = 'l'
				elif current_orientation == 'l':
					current_orientation = 'd'
				elif current_orientation == 'r':
					current_orientation = 'u'
				elif current_orientation == 'd':
					current_orientation = 'r'
			if move == 'R':
				if current_orientation == 'u':
					current_orientation = 'r'
				elif current_orientation == 'l':
					current_orientation = 'u'
				elif current_orientation == 'r':
					current_orientation = 'd'
				elif current_orientation == 'd':
					current_orientation = 'l'
		if position == (0, 0):
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		dir = 0
		for i in range(len(path)):
			if path[i] == 'L':
				dir = (4 + dir - 1) % 4
			elif path[i] == 'R':
				dir = (dir + 1) % 4
			elif dir == 0:
				y += 1
			elif dir == 1:
				x += 1
			elif dir == 2:
				y -= 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		dirX = [1, 0, -1, 0]
		dirY = [0, 1, 0, -1]
		dir = 0
		x = 0
		y = 0
		for i in path:
			if i == 'G':
				x += dirX[dir]
				y += dirY[dir]
			elif i == 'L':
				dir = (dir - 1) % 4
			else:
				dir = (dir + 1) % 4
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		directions = {'E': ['N', 'S'], 'W': ['S', 'N'], 'N': ['W', 'E'], 'S': ['E', 'W']}
		move = {'E': [1, 0], 'W': [-1, 0], 'N': [0, 1], 'S': [0, -1]}
		(X, Y) = (0, 0)
		towards = 'E'
		for p in path:
			if p == 'G':
				X += move[towards][0]
				Y += move[towards][1]
			else:
				towards = directions[towards][0] if p == 'L' else directions[towards][1]
		return 'Circular' if not X and (not Y) else 'Not Circular'


class Solution:

	def isCircular(self, path):
		(N, E, S, W) = (0, 1, 2, 3)
		dire = N
		(x, y) = (0, 0)
		n = len(path)
		for i in range(n):
			move = path[i]
			if move == 'R':
				dire = (dire + 1) % 4
			elif move == 'L':
				dire = (4 + dire - 1) % 4
			elif dire == N:
				y += 1
			elif dire == S:
				y -= 1
			elif dire == E:
				x += 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(dirx, diry) = (0, 1)
		(x, y) = (0, 0)
		for i in path:
			if i == 'G':
				(x, y) = (x + dirx, y + diry)
			elif i == 'L':
				(dirx, diry) = (-1 * diry, dirx)
			else:
				(dirx, diry) = (diry, -1 * dirx)
		if (x, y) == (0, 0):
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		face_up = [0, 1]
		face_d = [0, -1]
		face_l = [-1, 0]
		face_r = [1, 0]
		n = len(path) // 4 + 1
		dir = [face_up, face_l, face_d, face_r] * n
		position = [0, 0]
		current_pos = position
		ind = 0
		for i in path:
			if i == 'L':
				ind = ind + 1
			elif i == 'R':
				ind = ind - 1
			else:
				current_pos = [current_pos[0] + dir[ind][0], current_pos[1] + dir[ind][1]]
		if current_pos == position:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		facing = 'N'
		cord = [0, 0]
		for i in path:
			if i == 'G':
				if facing == 'N':
					cord[1] += 1
				elif facing == 'S':
					cord[1] -= 1
				elif facing == 'E':
					cord[0] += 1
				else:
					cord[0] -= 1
			elif i == 'L':
				if facing == 'N':
					facing = 'W'
				elif facing == 'S':
					facing = 'E'
				elif facing == 'E':
					facing = 'N'
				else:
					facing = 'S'
			elif facing == 'N':
				facing = 'E'
			elif facing == 'S':
				facing = 'W'
			elif facing == 'E':
				facing = 'S'
			else:
				facing = 'N'
		if cord[0] == cord[1] == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(dx, dy) = (0, 1)
		(x, y) = (0, 0)
		for d in path:
			if d == 'G':
				(x, y) = (x + dx, y + dy)
			elif d == 'L':
				(dx, dy) = (-1 * dy, dx)
			else:
				(dx, dy) = (dy, -1 * dx)
		if (x, y) == (0, 0):
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(x, y) = (0, 0)
		currDir = 'N'
		for c in path:
			if c == 'G':
				if currDir == 'N':
					x += 1
				elif currDir == 'W':
					y -= 1
				elif currDir == 'E':
					y += 1
				else:
					x -= 1
			elif c == 'L':
				if currDir == 'N':
					currDir = 'W'
				elif currDir == 'W':
					currDir = 'S'
				elif currDir == 'E':
					currDir = 'N'
				else:
					currDir = 'E'
			elif currDir == 'N':
				currDir = 'E'
			elif currDir == 'W':
				currDir = 'N'
			elif currDir == 'E':
				currDir = 'S'
			else:
				currDir = 'W'
		return 'Circular' if x == 0 and y == 0 else 'Not Circular'


class Solution:

	def isCircular(self, path):
		dir_l = ['y+', 'x+', 'y-', 'x-']
		d = {'y+': [0, 1], 'x+': [1, 0], 'y-': [0, -1], 'x-': [-1, 0]}
		curr_dir = 'y+'
		curr_co = [0, 0]
		for i in path:
			if i == 'G':
				(add_x, add_y) = d[curr_dir]
				curr_co = [curr_co[0] + add_x, curr_co[1] + add_y]
			else:
				curr_ind = dir_l.index(curr_dir)
				if i == 'R':
					if curr_ind + 1 == 4:
						curr_ind = 0
					else:
						curr_ind += 1
				elif curr_ind - 1 == -1:
					curr_ind = 3
				else:
					curr_ind -= 1
				curr_dir = dir_l[curr_ind]
		if curr_co == [0, 0]:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		if len(path) == 1:
			return 'Circular'
		N = 0
		E = 1
		S = 2
		W = 3
		x = 0
		y = 0
		dir = N
		for i in range(len(path)):
			move = path[i]
			if move == 'R':
				dir = (dir + 1) % 4
			elif move == 'L':
				dir = (4 + dir - 1) % 4
			elif dir == N:
				y += 1
			elif dir == E:
				x += 1
			elif dir == S:
				y -= 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		count = 1
		for i in range(len(path)):
			if path[i] == 'G':
				if count == 1:
					y += 1
				elif count == 2:
					x -= 1
				elif count == 3:
					y -= 1
				elif count == 4:
					x += 1
			elif path[i] == 'L':
				count += 1
				if count > 4:
					count = 1
			elif path[i] == 'R':
				count -= 1
				if count < 1:
					count = 4
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		count = 0
		direction = 'up'
		for c in path:
			if c == 'G':
				count += 1
			else:
				if c == 'L':
					if direction == 'up':
						y += count
						direction = 'left'
					elif direction == 'left':
						x -= count
						direction = 'down'
					elif direction == 'down':
						y -= count
						direction = 'right'
					elif direction == 'right':
						x += count
						direction = 'up'
				elif direction == 'up':
					y += count
					direction = 'right'
				elif direction == 'left':
					x -= count
					direction = 'up'
				elif direction == 'down':
					y -= count
					direction = 'left'
				elif direction == 'right':
					x += count
					direction = 'down'
				count = 0
		if direction == 'up':
			y += count
		elif direction == 'left':
			x -= count
		elif direction == 'down':
			y -= count
		elif direction == 'right':
			x += count
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def isCircular(self, path):
		direction = 'u'
		up = 0
		left = 0
		for i in range(len(path)):
			a = path[i]
			if a == 'G':
				if direction == 'u':
					up += 1
				elif direction == 'd':
					up -= 1
				elif direction == 'l':
					left += 1
				else:
					left -= 1
			elif a == 'L':
				if direction == 'u':
					direction = 'l'
				elif direction == 'l':
					direction = 'd'
				elif direction == 'd':
					direction = 'r'
				else:
					direction = 'u'
			elif a == 'R':
				if direction == 'u':
					direction = 'r'
				elif direction == 'r':
					direction = 'd'
				elif direction == 'd':
					direction = 'l'
				else:
					direction = 'u'
		if up == 0 and left == 0:
			return 'Circular'
		return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def __init__(self):
		self.orientation = 'North'
		self.coordinate = (0, 0)

	def changeorientation(self, i):
		if self.orientation == 'North' and i == 'L':
			self.orientation = 'Left'
		elif self.orientation == 'North' and i == 'R':
			self.orientation = 'Right'
		elif self.orientation == 'Left' and i == 'L':
			self.orientation = 'South'
		elif self.orientation == 'Left' and i == 'R':
			self.orientation = 'North'
		elif self.orientation == 'South' and i == 'L':
			self.orientation = 'Right'
		elif self.orientation == 'South' and i == 'R':
			self.orientation = 'Left'
		elif self.orientation == 'Right' and i == 'L':
			self.orientation = 'North'
		elif self.orientation == 'Right' and i == 'R':
			self.orientation = 'South'

	def movecoordinate(self, i):
		if self.orientation == 'North':
			self.coordinate = (self.coordinate[0], self.coordinate[1] + 1)
		elif self.orientation == 'Left':
			self.coordinate = (self.coordinate[0] - 1, self.coordinate[1])
		elif self.orientation == 'Right':
			self.coordinate = (self.coordinate[0] + 1, self.coordinate[1])
		elif self.orientation == 'South':
			self.coordinate = (self.coordinate[0], self.coordinate[1] - 1)

	def isCircular(self, path):
		for i in path:
			if i == 'L' or i == 'R':
				self.changeorientation(i)
			elif i == 'G':
				self.movecoordinate(i)
		if self.coordinate == (0, 0):
			return 'Circular'
		else:
			return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def isCircular(self, path):
		(sx, sy) = (0, 0)
		(x, y) = (0, 0)
		start_dir = 'N'
		dirc = start_dir
		for i in path:
			if i == 'L':
				if dirc == 'N':
					dirc = 'W'
				elif dirc == 'W':
					dirc = 'S'
				elif dirc == 'S':
					dirc = 'E'
				elif dirc == 'E':
					dirc = 'N'
			if i == 'R':
				if dirc == 'N':
					dirc = 'E'
				elif dirc == 'W':
					dirc = 'N'
				elif dirc == 'S':
					dirc = 'W'
				elif dirc == 'E':
					dirc = 'S'
			if i == 'G':
				if dirc == 'N':
					y = y + 1
				elif dirc == 'W':
					x = x - 1
				elif dirc == 'S':
					y = y - 1
				elif dirc == 'E':
					x = x + 1
		if sx == x and y == sy:
			return 'Circular'
		else:
			return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def isCircular(self, path):
		n = 0
		e = 1
		s = 2
		w = 3
		x = 0
		y = 0
		direc = n
		for i in range(len(path)):
			move = path[i]
			if move == 'R':
				direc = (direc + 1) % 4
			elif move == 'L':
				direc = (4 + direc - 1) % 4
			elif direc == n:
				y += 1
			elif direc == e:
				x += 1
			elif direc == s:
				y -= 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		path = input()
		solObj = Solution()
		print(solObj.isCircular(path))


class Solution:

	def isCircular(self, path):
		up = 0
		down = 0
		left = 0
		right = 0
		moving = 0
		for move in path:
			if move == 'G':
				if moving == 0:
					right = right + 1
				elif moving == 1:
					up = up + 1
				elif moving == 2:
					left = left + 1
				else:
					down = down + 1
			elif move == 'R':
				moving = (moving + 1) % 4
			elif moving == 0:
				moving = 3
			else:
				moving = moving - 1
		if up - down + left - right == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(x, y) = (0, 0)
		directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
		d = 0
		for i in path:
			if i == 'G':
				x += directions[d % 4][0]
				y += directions[d % 4][1]
			elif i == 'L':
				d -= 1
			else:
				d += 1
		return 'Circular' if (x, y) == (0, 0) else 'Not Circular'


N = 0
E = 1
S = 2
W = 3

def case_E(x, y):
	return (x + 1, y)

def case_W(x, y):
	return (x - 1, y)

def case_N(x, y):
	return (x, y + 1)

def case_S(x, y):
	return (x, y - 1)
options = {E: case_E, W: case_W, N: case_N, S: case_S}

class Solution:

	def isCircular(self, path):
		x = y = 0
		dir = N
		for i in range(len(path)):
			if path[i] == 'L':
				dir = (dir + 4 - 1) % 4
			elif path[i] == 'R':
				dir = (dir + 1) % 4
			else:
				(x, y) = options[dir](x, y)
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(curr_loc, first_loc) = ([0, 0], [0, 0])
		curr_dir = 'N'
		for move in path:
			if move == 'G':
				if curr_dir == 'N':
					curr_loc[1] += 1
				elif curr_dir == 'S':
					curr_loc[1] -= 1
				elif curr_dir == 'E':
					curr_loc[0] += 1
				elif curr_dir == 'W':
					curr_loc[0] -= 1
			elif move == 'L':
				if curr_dir == 'N':
					curr_dir = 'W'
				elif curr_dir == 'S':
					curr_dir = 'E'
				elif curr_dir == 'E':
					curr_dir = 'N'
				elif curr_dir == 'W':
					curr_dir = 'S'
			elif move == 'R':
				if curr_dir == 'N':
					curr_dir = 'E'
				elif curr_dir == 'S':
					curr_dir = 'W'
				elif curr_dir == 'E':
					curr_dir = 'S'
				elif curr_dir == 'W':
					curr_dir = 'N'
		if curr_loc == first_loc:
			return 'Circular'
		else:
			return 'Not Circular'


from collections import namedtuple
Point = namedtuple('Point', 'x y')

class Solution:

	def isCircular(self, path):
		p = Point(0, 0)
		direction = Point(1, 0)
		for e in path:
			if e == 'G':
				p = Point(p.x + direction.x, p.y + direction.y)
			elif e == 'L':
				direction = turn(direction, 'L')
			elif e == 'R':
				direction = turn(direction, 'R')
		return 'Circular' if p == (0, 0) else 'Not Circular'

def turn(currentDirection, dest):
	sign = 1 if dest == 'L' else -1
	if currentDirection == (1, 0):
		return Point(0, sign * 1)
	elif currentDirection == (0, 1):
		return Point(-1 * sign, 0)
	elif currentDirection == (-1, 0):
		return Point(0, -1 * sign)
	elif currentDirection == (0, -1):
		return Point(1 * sign, 0)
	else:
		return currentDirection


class Solution:

	def isCircular(self, path):
		(x, y) = (0, 0)
		directions = {'N': (0, 1), 'S': (0, -1), 'E': (1, 0), 'W': (-1, 0)}
		pos = 'N'
		n = len(path)
		for i in range(n):
			if path[i] == 'G':
				x = x + directions[pos][0]
				y = y + directions[pos][1]
			elif path[i] == 'L':
				if pos == 'N':
					pos = 'W'
				elif pos == 'W':
					pos = 'S'
				elif pos == 'S':
					pos = 'E'
				elif pos == 'E':
					pos = 'N'
			elif path[i] == 'R':
				if pos == 'N':
					pos = 'E'
				elif pos == 'E':
					pos = 'S'
				elif pos == 'S':
					pos = 'W'
				elif pos == 'W':
					pos = 'N'
		return 'Circular' if x == 0 and y == 0 else 'Not Circular'


class Solution:

	def isCircular(self, path):
		N = 1
		E = 2
		s = 3
		w = 4
		x = 0
		y = 0
		curr_dir = 1
		for i in path:
			if i == 'G':
				if curr_dir == 1:
					y += 1
				elif curr_dir == 2:
					x += 1
				elif curr_dir == 3:
					y -= 1
				else:
					x -= 1
			elif i == 'L':
				if curr_dir == 1:
					curr_dir = 4
				elif curr_dir == 2:
					curr_dir = 1
				elif curr_dir == 3:
					curr_dir = 2
				else:
					curr_dir = 3
			elif curr_dir == 1:
				curr_dir = 2
			elif curr_dir == 2:
				curr_dir = 3
			elif curr_dir == 3:
				curr_dir = 4
			else:
				curr_dir = 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		pos = [0, 0]
		ret = [0, 0]
		dirleft = {'l': 'd', 'd': 'r', 'r': 'u', 'u': 'l'}
		dirright = {'l': 'u', 'd': 'l', 'r': 'd', 'u': 'r'}
		move = 'r'
		for i in range(len(path)):
			if path[i] == 'G':
				if move == 'r':
					pos[1] += 1
				elif move == 'l':
					pos[1] -= 1
				elif move == 'u':
					pos[0] -= 1
				elif move == 'd':
					pos[0] += 1
			elif path[i] == 'L':
				move = dirleft[move]
			elif path[i] == 'R':
				move = dirright[move]
		if pos == ret:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = y = 0
		(dx, dy) = (1, 0)
		l = len(path)
		for i in range(l):
			if path[i] == 'L':
				if dx == 1:
					dx = 0
					dy = 1
				elif dy == 1:
					dx = -1
					dy = 0
				elif dy == -1:
					dx = 1
					dy = 0
				else:
					dx = 0
					dy = -1
				continue
			if path[i] == 'R':
				if dx == 1:
					dx = 0
					dy = -1
				elif dy == 1:
					dx = 1
					dy = 0
				elif dy == -1:
					dx = -1
					dy = 0
				else:
					dx = 0
					dy = 1
				continue
			x += dx
			y += dy
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(x, y, direc) = (0, 0, 0)
		for move in path:
			if move == 'L':
				direc = (4 + direc - 1) % 4
			if move == 'R':
				direc = (direc + 1) % 4
			if move == 'G':
				if direc == 0:
					y += 1
				elif direc == 1:
					x += 1
				elif direc == 2:
					y -= 1
				else:
					x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(x, y) = (0, 0)
		up = (0, 1)
		down = (0, -1)
		left = (-1, 0)
		right = (1, 0)
		left_turn = [down, left, up, right]
		right_turn = [up, left, down, right]
		current_direction = left
		for i in range(len(path)):
			if path[i] == 'G':
				x += current_direction[0]
				y += current_direction[1]
			else:
				if path[i] == 'L':
					turn = left_turn
				if path[i] == 'R':
					turn = right_turn
				index = turn.index(current_direction)
				index = 0 if index == 3 else index + 1
				current_direction = turn[index]
		return 'Circular' if (x, y) == (0, 0) else 'Not Circular'


class Solution:

	def isCircular(self, path):
		POSSIBLE_MOVEMENTS = {'N': [0, 1], 'S': [0, -1], 'E': [1, 0], 'W': [-1, 0]}
		POSSIBLE_DIRECTION_CHANGES = {'N': {'L': 'W', 'R': 'E'}, 'S': {'L': 'E', 'R': 'W'}, 'E': {'L': 'N', 'R': 'S'}, 'W': {'L': 'S', 'R': 'N'}}
		current_position = [0, 0]
		current_direction = 'N'
		for i in range(0, len(path)):
			if path[i] == 'G':
				current_position = self.addArrays(current_position, POSSIBLE_MOVEMENTS[current_direction])
			else:
				current_step = path[i]
				current_options = POSSIBLE_DIRECTION_CHANGES[current_direction]
				current_direction = current_options[current_step]
		if current_position == [0, 0]:
			return 'Circular'
		return 'Not Circular'

	def addArrays(self, arr1, arr2):
		array = [arr1[0] + arr2[0], arr1[1] + arr2[1]]
		return array


class Solution:

	def isCircular(self, path):
		x_count = 0
		y_count = 0
		direction = 'x'
		for char in path:
			if char == 'G' and direction == 'x':
				x_count += 1
			elif char == 'G' and direction == '-x':
				x_count -= 1
			elif char == 'G' and direction == 'y':
				y_count += 1
			elif char == 'G' and direction == '-y':
				y_count -= 1
			if char == 'L' and direction == 'x':
				direction = 'y'
			elif char == 'L' and direction == 'y':
				direction = '-x'
			elif char == 'L' and direction == '-x':
				direction = '-y'
			elif char == 'L' and direction == '-y':
				direction = 'x'
			elif char == 'R' and direction == 'x':
				direction = '-y'
			elif char == 'R' and direction == 'y':
				direction = 'x'
			elif char == 'R' and direction == '-x':
				direction = 'y'
			elif char == 'R' and direction == '-y':
				direction = '-x'
		if x_count == 0 and y_count == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		state_map = {'x+ve': (1, 0), 'x-ve': (-1, 0), 'y+ve': (0, 1), 'y-ve': (0, -1)}
		direct_map = {'x+ve': ('y+ve', 'y-ve'), 'x-ve': ('y-ve', 'y+ve'), 'y+ve': ('x-ve', 'x+ve'), 'y-ve': ('x+ve', 'x-ve')}
		state = ('x+ve', (0, 0))
		for char in path:
			(direct, cord) = state
			if char == 'G':
				(dx, dy) = state_map[direct]
				new_cord = (cord[0] + dx, cord[1] + dy)
				new_state = (direct, new_cord)
			else:
				if char == 'L':
					new_direct = direct_map[direct][0]
				else:
					new_direct = direct_map[direct][1]
				new_state = (new_direct, cord)
			state = new_state
		return 'Circular' if state[1] == (0, 0) else 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		directions = ['N', 'E', 'S', 'W']
		index = 0
		for i in range(len(path)):
			move = path[i]
			if move == 'R':
				index = (index + 1) % 4
			elif move == 'L':
				index = (4 + index - 1) % 4
			else:
				d = directions[index]
				if d == 'N':
					y += 1
				elif d == 'E':
					x += 1
				elif d == 'S':
					y -= 1
				else:
					x -= 1
		return 'Circular' if x == 0 and y == 0 else 'Not Circular'


class Solution:

	def isCircular(self, path):
		d = [[0, 1], [-1, 0], [0, -1], [1, 0]]
		dir = 0
		x = y = 0
		for p in path:
			if p == 'L':
				dir = (dir + 1) % 4
			elif p == 'R':
				dir = (dir + 3) % 4
			else:
				(x, y) = (x + d[dir][0], y + d[dir][1])
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		i = 0
		x = 0
		y = 0
		d = 0
		while i < len(path):
			if path[i] == 'L':
				d -= 1
				i += 1
			elif path[i] == 'R':
				d += 1
				i += 1
			elif path[i] == 'G':
				d = d % 4
				if d == -1 or d == 3:
					x -= 1
				elif d == 1 or d == -3:
					x += 1
				elif d == -2 or d == 2:
					y -= 1
				elif d == 0:
					y += 1
				i += 1
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		directions = {'0': 0, '90': 0, '180': 0, '270': 0}
		heading = 0
		for step in path:
			if step == 'G':
				directions[str(heading)] = directions[str(heading)] + 1
			elif step == 'L':
				heading = (heading + 90) % 360
			elif step == 'R':
				heading = (heading - 90) % 360
			if heading < 0:
				heading = 360 + heading
		if directions['0'] - directions['180'] + (directions['90'] - directions['270']) == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		final_pos = 0
		(x, y) = (0, 0)
		head = 1
		for i in path:
			if i == 'L' and head == 1:
				head = 2
			elif i == 'L' and head == 2:
				head = 3
			elif i == 'L' and head == 3:
				head = 4
			elif i == 'L' and head == 4:
				head = 1
			elif i == 'R' and head == 1:
				head = 4
			elif i == 'R' and head == 2:
				head = 1
			elif i == 'R' and head == 3:
				head = 2
			elif i == 'R' and head == 4:
				head = 3
			elif head == 1:
				x += 1
			elif head == 2:
				y += 1
			elif head == 3:
				x -= 1
			else:
				y -= 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):

		def walk(pathUnit, walkRecord, pointer):
			if pointer == 3 and pathUnit == 'L':
				pointer = 0
			elif pointer == 0 and pathUnit == 'R':
				pointer = 3
			elif pathUnit == 'L':
				pointer += 1
			elif pathUnit == 'R':
				pointer -= 1
			if pathUnit == 'G':
				if pointer == 0:
					walkRecord[0] += 1
				if pointer == 1:
					walkRecord[1] += 1
				if pointer == 2:
					walkRecord[2] += 1
				if pointer == 3:
					walkRecord[3] += 1
			return (walkRecord, pointer)
		walkRecord = [0] * 4
		pointer = 0
		for pathUnit in path:
			(walkRecord, pointer) = walk(pathUnit, walkRecord, pointer)
		if walkRecord[0] + walkRecord[1] == walkRecord[2] + walkRecord[3]:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(n, e, s, w) = (0, 1, 2, 3)
		(x, y) = (0, 0)
		d = n
		for i in path:
			if i == 'R':
				d = (d + 1) % 4
			elif i == 'L':
				d = (4 + d - 1) % 4
			elif d == n:
				y += 1
			elif d == e:
				x += 1
			elif d == s:
				y -= 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		direction = 'right'
		init_x = init_y = 0
		for move in path:
			if move == 'G':
				if direction == 'right':
					init_x += 1
				elif direction == 'left':
					init_x -= 1
				elif direction == 'up':
					init_y += 1
				elif direction == 'down':
					init_y -= 1
			elif move == 'L':
				if direction == 'right':
					direction = 'up'
				elif direction == 'up':
					direction = 'left'
				elif direction == 'left':
					direction = 'down'
				elif direction == 'down':
					direction = 'right'
			elif move == 'R':
				if direction == 'right':
					direction = 'down'
				elif direction == 'down':
					direction = 'left'
				elif direction == 'left':
					direction = 'up'
				elif direction == 'up':
					direction = 'right'
		if init_x == init_y and init_x == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		direction = 'n'
		n = 0
		e = 0
		s = 0
		w = 0
		for p in path:
			if p == 'R':
				if direction == 'n':
					direction = 'e'
				elif direction == 'e':
					direction = 's'
				elif direction == 's':
					direction = 'w'
				else:
					direction = 'n'
			elif p == 'L':
				if direction == 'n':
					direction = 'w'
				elif direction == 'e':
					direction = 'n'
				elif direction == 's':
					direction = 'e'
				else:
					direction = 's'
			elif direction == 'n':
				n += 1
				if s > 0:
					n -= 1
					s -= 1
			elif direction == 'e':
				e += 1
				if w > 0:
					e -= 1
					w -= 1
			elif direction == 's':
				s += 1
				if n > 0:
					n -= 1
					s -= 1
			else:
				w += 1
				if e > 0:
					e -= 1
					w -= 1
		if n - s == 0 and e - w == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		face = 0
		for chars in path:
			if chars == 'G':
				if face == 0:
					x += 1
				elif face == 1:
					y += 1
				elif face == 2:
					x -= 1
				else:
					y -= 1
			elif chars == 'L':
				face += 1
				face %= 4
			elif chars == 'R':
				face -= 1
				if face < 0:
					face = 3
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:
	position = [0, 0]
	direction = 'North'

	def isCircular(self, path):
		if not 1 <= len(path) <= pow(10, 5):
			return 'Not Circular'
		position = [0, 0]
		direction = 'North'
		for s in path:
			if s == 'L':
				if direction == 'North':
					direction = 'West'
				elif direction == 'West':
					direction = 'South'
				elif direction == 'South':
					direction = 'East'
				elif direction == 'East':
					direction = 'North'
			if s == 'R':
				if direction == 'North':
					direction = 'East'
				elif direction == 'East':
					direction = 'South'
				elif direction == 'South':
					direction = 'West'
				elif direction == 'West':
					direction = 'North'
			if s == 'G':
				if direction == 'North':
					position = [a + b for (a, b) in zip(position, [0, 1])]
				elif direction == 'East':
					position = [a + b for (a, b) in zip(position, [1, 0])]
				elif direction == 'South':
					position = [a + b for (a, b) in zip(position, [0, -1])]
				elif direction == 'West':
					position = [a + b for (a, b) in zip(position, [-1, 0])]
		if position == [0, 0]:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def __init__(self):
		self.x = 0
		self.y = 0
		self.direction = [0, 1]

	def isCircular(self, path):
		for c in path:
			if c == 'G':
				self.x += self.direction[0]
				self.y += self.direction[1]
			if c == 'L':
				self.direction = [-1 * self.direction[1], self.direction[0] * 1]
			if c == 'R':
				self.direction = [1 * self.direction[1], self.direction[0] * -1]
		if self.x == 0 and self.y == 0:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		N = 0
		E = 1
		S = 2
		W = 3
		x = 0
		y = 0
		direction = 0
		for move in list(path):
			if move == 'L':
				direction = (direction + 1) % 4
			elif move == 'R':
				direction = (4 + direction - 1) % 4
			else:
				if direction == 0:
					y += 1
				if direction == 1:
					x += 1
				if direction == 2:
					y -= 1
				if direction == 3:
					x -= 1
		return 'Circular' if x == 0 and y == 0 else 'Not Circular'


class Solution:

	def isCircular(self, path):
		dirn = 'E'
		(x, y) = (0, 0)
		for i in range(len(path)):
			if path[i] == 'G':
				if dirn == 'E':
					y += 1
				elif dirn == 'W':
					y -= 1
				elif dirn == 'N':
					x -= 1
				else:
					x += 1
			elif path[i] == 'L':
				if dirn == 'E':
					dirn = 'N'
				elif dirn == 'W':
					dirn = 'S'
				elif dirn == 'N':
					dirn = 'W'
				else:
					dirn = 'E'
			elif dirn == 'E':
				dirn = 'S'
			elif dirn == 'W':
				dirn = 'N'
			elif dirn == 'N':
				dirn = 'E'
			else:
				dirn = 'W'
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		loc = [0, 0]
		dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)]
		current_dir = 0 % 4
		for p in path:
			if p == 'G':
				loc[0] += dirs[current_dir][0]
				loc[1] += dirs[current_dir][1]
			elif p == 'L':
				current_dir = (current_dir - 1) % 4
			else:
				current_dir = (current_dir + 1) % 4
		return 'Circular' if loc == [0, 0] else 'Not Circular'


class Solution:

	def isCircular(self, path):
		N = 0
		E = 1
		S = 2
		W = 3
		x = 0
		y = 0
		dir = N
		for item in path:
			if item == 'L':
				dir = (4 + dir - 1) % 4
			elif item == 'R':
				dir = (dir + 1) % 4
			elif dir == N:
				y += 1
			elif dir == E:
				x += 1
			elif dir == S:
				y -= 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		x = 0
		y = 0
		cp = 4
		for ch in path:
			if ch == 'L':
				cp += 1
			elif ch == 'R':
				cp -= 1
			elif cp % 4 == 0:
				x += 1
			elif cp % 4 == 1:
				y += 1
			elif cp % 4 == 2:
				x -= 1
			elif cp % 4 == 3:
				y -= 1
		if x == y and x == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, moves):
		x = y = 0
		present_direction = 0
		for move in moves:
			if move == 'L':
				present_direction = (4 + present_direction - 1) % 4
			elif move == 'R':
				present_direction = (present_direction + 1) % 4
			elif present_direction == 0:
				y += 1
			elif present_direction == 2:
				y -= 1
			elif present_direction == 3:
				x += 1
			else:
				x -= 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		flag = [(-1, 0), (0, 1), (1, 0), (0, -1)]
		cur = 1
		init = (0, 0)
		pos = (0, 0)
		for c in path:
			if c == 'G':
				pos = tuple(map(lambda a, b: a + b, pos, flag[cur]))
			elif c == 'L':
				cur = (3 + cur) % 4
			else:
				cur = (1 + cur) % 4
		if pos == init:
			return 'Circular'
		return 'Not Circular'


class Solution:

	def isCircular(self, path):
		(x, y) = (0, 0)
		currentDirection = 'N'
		turn = {'NL': 'W', 'NR': 'E', 'EL': 'N', 'ER': 'S', 'SL': 'E', 'SR': 'W', 'WL': 'S', 'WR': 'N'}
		for i in path:
			if i == 'G':
				if currentDirection == 'N':
					x += 1
				elif currentDirection == 'S':
					x -= 1
				elif currentDirection == 'E':
					y += 1
				elif currentDirection == 'W':
					y -= 1
			else:
				currentDirection = turn[currentDirection + i]
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, list_of_commands):
		compass = 0
		orientation = 'N'
		x = 0
		y = 0
		for command in list_of_commands:
			if command == 'G':
				if orientation == 'N':
					y += 1
				if orientation == 'S':
					y -= 1
				if orientation == 'E':
					x += 1
				if orientation == 'W':
					x -= 1
			if command == 'L':
				if compass == 0:
					compass = 3
				else:
					compass -= 1
			if command == 'R':
				if compass == 3:
					compass = 0
				else:
					compass += 1
			if compass == 0:
				orientation = 'N'
			if compass == 1:
				orientation = 'E'
			if compass == 2:
				orientation = 'S'
			if compass == 3:
				orientation = 'W'
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		dir = 'east'
		x = 0
		y = 0
		for i in path:
			if i == 'L':
				if dir == 'east':
					dir = ''
					dir = 'north'
				elif dir == 'north':
					dir = ''
					dir = 'west'
				elif dir == 'west':
					dir = ''
					dir = 'south'
				elif dir == 'south':
					dir = ''
					dir = 'east'
			elif i == 'R':
				if dir == 'east':
					dir = ''
					dir = 'south'
				elif dir == 'south':
					dir = ''
					dir = 'west'
				elif dir == 'west':
					dir = ''
					dir = 'north'
				elif dir == 'north':
					dir = ''
					dir = 'east'
			elif i == 'G':
				if dir == 'east':
					x = x + 1
				elif dir == 'west':
					x = x - 1
				elif dir == 'north':
					y = y + 1
				elif dir == 'south':
					y = y - 1
		if x == 0 and y == 0:
			return 'Circular'
		else:
			return 'Not Circular'


class Solution:

	def isCircular(self, path):
		start = [0, 0]
		modify = 'X+'
		nextmodify = {('X+', 'L'): 'Y+', ('X+', 'R'): 'Y-', ('X-', 'L'): 'Y-', ('X-', 'R'): 'Y+', ('Y+', 'L'): 'X-', ('Y+', 'R'): 'X+', ('Y-', 'L'): 'X+', ('Y-', 'R'): 'X-'}
		for move in path:
			if move == 'G':
				if modify == 'X+':
					start[0] = start[0] + 1
				elif modify == 'X-':
					start[0] = start[0] - 1
				elif modify == 'Y+':
					start[1] = start[1] + 1
				elif modify == 'Y-':
					start[1] = start[1] - 1
			else:
				modify = nextmodify[modify, move]
		return 'Circular' if start[0] == 0 and start[1] == 0 else 'Not Circular'