"""simple docstring"""






import math






class     A:

		"""simple docstring"""





		def __init__(   self				,							SCREAMING_SNAKE_CASE__      )			->  Dict:

					"""simple docstring"""



					_UpperCamelCase				:List[str]				    =  len(SCREAMING_SNAKE_CASE__      )
					_UpperCamelCase				:List[str]				    =  [0] * (
					    4 * self.N
					)  # approximate the overall size of segment tree with array N
					self.build(1				,							0				,							self.N - 1      )
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__      )			->  Optional[int]:

					"""simple docstring"""



					return idx * 2
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__      )			->  Tuple:

					"""simple docstring"""



					return idx * 2 + 1
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )			->  Optional[int]:  # noqa: E741

					"""simple docstring"""



					if l == r:
								_UpperCamelCase				:str				    =  A[l]
					else:
								_UpperCamelCase				:Optional[int]				    =  (l + r) // 2
								self.build(self.left(SCREAMING_SNAKE_CASE__      )				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )
								self.build(self.right(SCREAMING_SNAKE_CASE__      )				,							mid + 1				,							SCREAMING_SNAKE_CASE__      )
								_UpperCamelCase				:Dict				    =  max(self.st[self.left(SCREAMING_SNAKE_CASE__      )]				,							self.st[self.right(SCREAMING_SNAKE_CASE__      )]      )
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )			->  Dict:

					"""simple docstring"""



					return self.update_recursive(1				,							0				,							self.N - 1				,							a - 1				,							b - 1				,							SCREAMING_SNAKE_CASE__      )
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )			->  Dict:  # noqa: E741

					"""simple docstring"""



					if r < a or l > b:
								return True
					if l == r:
								_UpperCamelCase				:Optional[int]				    =  val
								return True
					_UpperCamelCase				:List[str]				    =  (l + r) // 2
					self.update_recursive(self.left(SCREAMING_SNAKE_CASE__      )				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )
					self.update_recursive(self.right(SCREAMING_SNAKE_CASE__      )				,							mid + 1				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )
					_UpperCamelCase				:Optional[int]				    =  max(self.st[self.left(SCREAMING_SNAKE_CASE__      )]				,							self.st[self.right(SCREAMING_SNAKE_CASE__      )]      )
					return True
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )			->  int:

					"""simple docstring"""



					return self.query_recursive(1				,							0				,							self.N - 1				,							a - 1				,							b - 1      )
		def      _UpperCamelCase(   self				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )			->  List[str]:  # noqa: E741

					"""simple docstring"""



					if r < a or l > b:
								return -math.inf
					if l >= a and r <= b:
								return self.st[idx]
					_UpperCamelCase				:Tuple				    =  (l + r) // 2
					_UpperCamelCase				:Optional[Any]				    =  self.query_recursive(self.left(SCREAMING_SNAKE_CASE__      )				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )
					_UpperCamelCase				:Dict				    =  self.query_recursive(self.right(SCREAMING_SNAKE_CASE__      )				,							mid + 1				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )
					return max(SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )





		def      _UpperCamelCase(   self      )			->  int:

					"""simple docstring"""



					_UpperCamelCase				:str				    =  []
					for i in range(1				,							N + 1      ):
								show_list += [self.query(SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__      )]
					print(SCREAMING_SNAKE_CASE__      )


if __name__ == "__main__":
					UpperCamelCase__							:int       =  [1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
					UpperCamelCase__							:Dict       =  15
					UpperCamelCase__							:List[Any]       =  SegmentTree(A)
					print(segt.query(4, 6))
					print(segt.query(7, 11))
					print(segt.query(7, 12))
					segt.update(1, 3, 111)
					print(segt.query(1, 15))
					segt.update(7, 8, 235)
					segt.show_data()





"""simple docstring"""






def 							A_					(   snake_case__		)				->     str:
			_UpperCamelCase				:Tuple				    =  word.upper()
			_UpperCamelCase				:Dict				    =  0
			_UpperCamelCase				:Union[str, Any]				    =  {}
			_UpperCamelCase				:Optional[int]				    =  []

			for letter in word:
						if letter not in letter_nums:
									_UpperCamelCase				:Dict				    =  str(snake_case__		)
									next_num += 1
						word_pattern.append(letter_nums[letter]		)
			return ".".join(snake_case__		)


if __name__ == "__main__":
					import pprint
					import time

					UpperCamelCase__							:Dict       =  time.time()
					with open("""dictionary.txt""") as in_file:
										UpperCamelCase__							:str       =  in_file.read().splitlines()

					UpperCamelCase__							:dict       =  {}
					for word in word_list:
										UpperCamelCase__							:List[Any]       =  get_word_pattern(word)
										if pattern in all_patterns:
															all_patterns[pattern].append(word)
										else:
															UpperCamelCase__							:Tuple       =  [word]

					with open("""word_patterns.txt""", """w""") as out_file:
										out_file.write(pprint.pformat(all_patterns))

					UpperCamelCase__							:Dict       =  round(time.time() - start_time, 2)
					print(F"""Done!  {len(all_patterns):,} word patterns found in {total_time} seconds.""")
					# Done!  9,581 word patterns found in 0.58 seconds.

