


'''simple docstring'''



from __future__ import annotations




def 			_a			(		_lowercase      :			int						):





     '''simple docstring'''






     __UpperCAmelCase			:				Tuple													=    str(__lowercase						)
     return len(__lowercase						) == 9 and set(__lowercase						) == set('''123456789'''						)




def 			_a			(		):





     '''simple docstring'''






     for base_num in range(9999    ,      4999    ,      -1						):
          __UpperCAmelCase			:				List[str]													=    100002 * base_num
          if is_9_pandigital(__lowercase						):
               return candidate

     for base_num in range(333    ,      99    ,      -1						):
          __UpperCAmelCase			:				Tuple													=    1002003 * base_num
          if is_9_pandigital(__lowercase						):
               return candidate

     return None


if __name__ == "__main__":
      print(f"""{solution() = }""")








'''simple docstring'''



def 			_a			(		_lowercase      :			list[list[int]]    ,      _lowercase      :			int    ,      _lowercase      :			int    ,      _lowercase      :			set						):





     '''simple docstring'''






     __UpperCAmelCase							,     __UpperCAmelCase			:				Any													=    len(_lowercase						), len(grid[0]						)
     if (
         min(_lowercase    ,      _lowercase						) < 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			:				Optional[Any]													=    0
     count += depth_first_search(_lowercase    ,      row + 1    ,      _lowercase    ,      _lowercase						)
     count += depth_first_search(_lowercase    ,      row - 1    ,      _lowercase    ,      _lowercase						)
     count += depth_first_search(_lowercase    ,      _lowercase    ,      col + 1    ,      _lowercase						)
     count += depth_first_search(_lowercase    ,      _lowercase    ,      col - 1    ,      _lowercase						)

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


if __name__ == "__main__":
      import doctest

      doctest.testmod()