
"""simple docstring"""

from __future__ import annotations

from collections import deque
class      _UpperCAmelCase							:




						def __init__(							self   ,       lowercase_							)						->					List[Any]:
										UpperCAmelCase									=					[]
										self.adlist.append(
										    {'value': '', 'next_states': [], 'fail_state': 0, 'output': []}							)

										for keyword in keywords:
														self.add_keyword(_A							)
										self.set_fail_transitions()




						def     a_      (							self   ,       lowercase_   ,       lowercase_							)						->					List[str]:
										for state in self.adlist[current_state]["next_states"]:
														if char == self.adlist[state]["value"]:
																		return state
										return None




						def     a_      (							self   ,       lowercase_							)						->					Tuple:
										UpperCAmelCase									=					0
										for character in keyword:
														UpperCAmelCase									=					self.find_next_state(_A   ,       _A							)
														if next_state is None:
																		self.adlist.append(
																		    {
																		        'value': character,
																		        'next_states': [],
																		        'fail_state': 0,
																		        'output': [],
																		    }							)
																		self.adlist[current_state]["next_states"].append(len(self.adlist							) - 1							)
																		UpperCAmelCase									=					len(self.adlist							) - 1
														else:
																		UpperCAmelCase									=					next_state
										self.adlist[current_state]["output"].append(_A							)




						def     a_      (							self							)						->					Any:
										UpperCAmelCase									=					deque()
										for node in self.adlist[0]["next_states"]:
														q.append(_A							)
														UpperCAmelCase									=					0
										while q:
														UpperCAmelCase									=					q.popleft()
														for child in self.adlist[r]["next_states"]:
																		q.append(_A							)
																		UpperCAmelCase									=					self.adlist[r]['fail_state']
																		while (
																		    self.find_next_state(_A   ,       self.adlist[child]['value']							) is None
																		    and state != 0
																		):
																						UpperCAmelCase									=					self.adlist[state]['fail_state']
																		UpperCAmelCase									=					self.find_next_state(
																		    _A   ,       self.adlist[child]['value']							)
																		if self.adlist[child]["fail_state"] is None:
																						UpperCAmelCase									=					0
																		UpperCAmelCase									=					(
																		    self.adlist[child]['output']
																		    + self.adlist[self.adlist[child]['fail_state']]['output']
																		)




						def     a_      (							self   ,       lowercase_							)						->					List[Any]:
										UpperCAmelCase									=					{}  # returns a dict with keywords and list of its occurrences
										UpperCAmelCase									=					0
										for i in range(len(_A							)							):
														while (
														    self.find_next_state(_A   ,       string[i]							) is None
														    and current_state != 0
														):
																		UpperCAmelCase									=					self.adlist[current_state]['fail_state']
														UpperCAmelCase									=					self.find_next_state(_A   ,       string[i]							)
														if next_state is None:
																		UpperCAmelCase									=					0
														else:
																		UpperCAmelCase									=					next_state
																		for key in self.adlist[current_state]["output"]:
																						if key not in result:
																										UpperCAmelCase									=					[]
																						result[key].append(i - len(_A							) + 1							)
										return result


if __name__ == "__main__":
			import doctest

			doctest.testmod()





"""simple docstring"""

def     lowercase__						(					lowerCAmelCase				:					int ,				lowerCAmelCase				:					int ) ->      int:






    """simple docstring"""




    return int((input_a, input_a).count(0 ) == 0 )




def     lowercase__						(					) ->      None:






    """simple docstring"""




    assert and_gate(0 ,				0 ) == 0
    assert and_gate(0 ,				1 ) == 0
    assert and_gate(1 ,				0 ) == 0
    assert and_gate(1 ,				1 ) == 1


if __name__ == "__main__":
   test_and_gate()
   print(and_gate(1, 0))
   print(and_gate(0, 0))
   print(and_gate(0, 1))
   print(and_gate(1, 1))



