




'''simple docstring'''





def UpperCAmelCase    (       UpperCAmelCase_						):
    # must be
    _a				:							Optional[Any]							       =      [list(UpperCAmelCase_						) for row in matrix]
    if matrix and isinstance(UpperCAmelCase_   ,	UpperCAmelCase_						):
        if isinstance(matrix[0]   ,	UpperCAmelCase_						):
            _a				:							int							       =      0
            for row in matrix:
                if prev_len == 0:
                    _a				:							Any							       =      len(UpperCAmelCase_						)
                    _a				:							Optional[Any]							       =      True
                else:
                    _a				:							List[Any]							       =      prev_len == len(UpperCAmelCase_						)
        else:
            _a				:							Dict							       =      True
    else:
        _a				:							Dict							       =      False

    return result





def UpperCAmelCase    (       UpperCAmelCase_						):
    if check_matrix(UpperCAmelCase_						) and len(UpperCAmelCase_						) > 0:
        _a				:							Tuple							       =      [list(UpperCAmelCase_						) for row in a]
        _a				:							Union[str, Any]							       =      len(UpperCAmelCase_						)
        if isinstance(a[0]   ,	UpperCAmelCase_						):
            _a				:							Union[str, Any]							       =      len(a[0]						)
        else:
            for dat in a:
                print(UpperCAmelCase_						)
            return

        # horizotal printing increasing
        for i in range(0   ,	UpperCAmelCase_						):
            print(a[0][i]						)
        # vertical printing down
        for i in range(1   ,	UpperCAmelCase_						):
            print(a[i][mat_col - 1]						)
        # horizotal printing decreasing
        if mat_row > 1:
            for i in range(mat_col - 2   ,	-1   ,	-1						):
                print(a[mat_row - 1][i]						)
        # vertical printing up
        for i in range(mat_row - 2   ,	0   ,	-1						):
            print(a[i][0]						)
        _a				:							List[str]							       =      [row[1 : mat_col - 1] for row in a[1 : mat_row - 1]]
        if len(UpperCAmelCase_						) > 0:
            spiral_print_clockwise(UpperCAmelCase_						)
        else:
            return
    else:
        print("""Not a valid matrix"""						)
        return





def UpperCAmelCase    (       UpperCAmelCase_						):
    if matrix:
        return list(matrix.pop(0						)						) + spiral_traversal(list(zip(*UpperCAmelCase_						)						)[::-1]						)
    else:
        return []


# driver code
if __name__ == "__main__":
  import doctest

  doctest.testmod()

  a		:	str       =      [[1, 2, 3, 4], [5, 6, 7, 8], [9, 1_0, 1_1, 1_2]]
  spiral_print_clockwise(a)










from __future__ import annotations







def 						_UpperCamelCase (     UpperCamelCase_							:       list[int]		)	-> list[int]:

						"""simple docstring"""



						if not list_of_ints:
												return []

						if min(UpperCamelCase_		) < 0:
												raise ValueError('All numbers must be positive'		)

						lowerCAmelCase__         =    max(len(bin(UpperCamelCase_		)[2:]		) for x in list_of_ints		)
						return _msd_radix_sort(UpperCamelCase_     ,							UpperCamelCase_		)







def 						_UpperCamelCase (     UpperCamelCase_							:       list[int]     ,							UpperCamelCase_							:       int		)	-> list[int]:

						"""simple docstring"""



						if bit_position == 0 or len(UpperCamelCase_		) in [0, 1]:
												return list_of_ints

						lowerCAmelCase__         =    []
						lowerCAmelCase__         =    []
						# Split numbers based on bit at bit_position from the right
						for number in list_of_ints:
												if (number >> (bit_position - 1)) & 1:
																		# number has a one at bit bit_position
																		ones.append(UpperCamelCase_		)
												else:
																		# number has a zero at bit bit_position
																		zeros.append(UpperCamelCase_		)

    # recursively split both lists further
						lowerCAmelCase__         =    _msd_radix_sort(UpperCamelCase_     ,							bit_position - 1		)
						lowerCAmelCase__         =    _msd_radix_sort(UpperCamelCase_     ,							bit_position - 1		)

						# recombine lists
						lowerCAmelCase__         =    zeros
						res.extend(UpperCamelCase_		)

						return res







def 						_UpperCamelCase (     UpperCamelCase_							:       list[int]		)	-> Any:

						"""simple docstring"""



						lowerCAmelCase__         =    len(UpperCamelCase_		)
						if not list_of_ints or length == 1:
												return

						if min(UpperCamelCase_		) < 0:
												raise ValueError('All numbers must be positive'		)

						lowerCAmelCase__         =    max(len(bin(UpperCamelCase_		)[2:]		) for x in list_of_ints		)
						_msd_radix_sort_inplace(UpperCamelCase_     ,							UpperCamelCase_     ,							0     ,							UpperCamelCase_		)







def 						_UpperCamelCase (     UpperCamelCase_							:       list[int]     ,							UpperCamelCase_							:       int     ,							UpperCamelCase_							:       int     ,							UpperCamelCase_							:       int		)	-> int:

						"""simple docstring"""



						if bit_position == 0 or end_index - begin_index <= 1:
												return

						bit_position -= 1

						lowerCAmelCase__         =    begin_index
						lowerCAmelCase__         =    end_index - 1
						while i <= j:
												lowerCAmelCase__         =    False
												if not (list_of_ints[i] >> bit_position) & 1:
																		# found zero at the beginning
																		i += 1
																		lowerCAmelCase__         =    True
												if (list_of_ints[j] >> bit_position) & 1:
																		# found one at the end
																		j -= 1
																		lowerCAmelCase__         =    True

												if changed:
																		continue

												lowerCAmelCase__    ,							lowerCAmelCase__         =    list_of_ints[j], list_of_ints[i]
												j -= 1
												if j != i:
																		i += 1

						_msd_radix_sort_inplace(UpperCamelCase_     ,							UpperCamelCase_     ,							UpperCamelCase_     ,							UpperCamelCase_		)
						_msd_radix_sort_inplace(UpperCamelCase_     ,							UpperCamelCase_     ,							UpperCamelCase_     ,							UpperCamelCase_		)


if __name__ == "__main__":
					import doctest

					doctest.testmod()





