
"""simple docstring"""



def 			_UpperCamelCase						(    _A       ,   _A       ,   _A       ,   _A   )     ->	int:





    """simple docstring"""

    _UpperCAmelCase        = len(A__   ), len(grid[0]   )
    if (
        min(A__       ,   A__   ) < 0
        or row == row_length
        or col == col_length
        or (row, col) in visit
        or grid[row][col] == 1
    ):
        return 0
    if row == row_length - 1 and col == col_length - 1:
        return 1

    visit.add((row, col)   )

    _UpperCAmelCase        = 0
    count += depth_first_search(A__       ,   row + 1       ,   A__       ,   A__   )
    count += depth_first_search(A__       ,   row - 1       ,   A__       ,   A__   )
    count += depth_first_search(A__       ,   A__       ,   col + 1       ,   A__   )
    count += depth_first_search(A__       ,   A__       ,   col - 1       ,   A__   )

    visit.remove((row, col)   )
    return count


if __name__ == "__main__":
 import doctest

 doctest.testmod()







"""simple docstring"""
def 							snake_case (  A__		):
			UpperCAmelCase_	:					int     	=   [0 for i in range(len(A__		)		)]

			# initialize interval's left pointer and right pointer
			UpperCAmelCase_	,      UpperCAmelCase_	:					Optional[int]     	=   0, 0

			for i in range(1      ,len(A__		)		):
						# case when current index is inside the interval
						if i <= right_pointer:
									UpperCAmelCase_	:					Any     	=   min(right_pointer - i + 1      ,z_result[i - left_pointer]		)
									UpperCAmelCase_	:					Union[str, Any]     	=   min_edge

						while go_next(A__      ,A__      ,A__		):
									z_result[i] += 1

						# if new index's result gives us more right interval,
						# we've to update left_pointer and right_pointer
						if i + z_result[i] - 1 > right_pointer:
									UpperCAmelCase_	,      UpperCAmelCase_	:					Union[str, Any]     	=   i, i + z_result[i] - 1

			return z_result

def 							snake_case (  A__      ,A__      ,A__		):
			return i + z_result[i] < len(A__		) and s[z_result[i]] == s[i + z_result[i]]

def 							snake_case (  A__      ,A__		):
			UpperCAmelCase_	:					Optional[int]     	=   0
			# concatenate 'pattern' and 'input_str' and call z_function
			# with concatenated string
			UpperCAmelCase_	:					Tuple     	=   z_function(pattern + input_str		)

			for val in z_result:
						# if value is greater then length of the pattern string
						# that means this index is starting position of substring
						# which is equal to pattern string
						if val >= len(A__		):
									answer += 1

			return answer


if __name__ == "__main__":
			import doctest

			doctest.testmod()



