





from __future__ import annotations



def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase  )		->				list[list[int]]:
 UpperCamelCase			:      list[list[int]] 			=     []
 create_all_state(1							,     _lowerCAmelCase							,     _lowerCAmelCase							,     []							,     _lowerCAmelCase  )
 return result



def 	A_       (  _lowerCAmelCase							,     _lowerCAmelCase							,     _lowerCAmelCase							,     _lowerCAmelCase							,     _lowerCAmelCase							,     )		->				None:
 if level == 0:
  total_list.append(current_list[:]  )
  return

 for i in range(_lowerCAmelCase							,     total_number - level + 2  ):
  current_list.append(_lowerCAmelCase  )
  create_all_state(i + 1							,     _lowerCAmelCase							,     level - 1							,     _lowerCAmelCase							,     _lowerCAmelCase  )
  current_list.pop()



def 	A_       (  _lowerCAmelCase  )		->				None:
 for i in total_list:
  print(*_lowerCAmelCase  )


if __name__ == "__main__":
    __lowerCamelCase :  Tuple										=  4
    __lowerCamelCase :  Any										=  2
    __lowerCamelCase :  List[str]										=  generate_all_combinations(n, k)
    print_all_state(total_list)







from PIL import Image



def 	A_       (  _lowerCAmelCase  )		->				Image:
 UpperCamelCase			,					UpperCamelCase			:      List[Any] 			=     image.size
 UpperCamelCase			:      Union[str, Any] 			=     0
 UpperCamelCase			:      List[str] 			=     image.load()
 for i in range(_lowerCAmelCase  ):
  for j in range(_lowerCAmelCase  ):
   UpperCamelCase			:      List[Any] 			=     pixels[j, i]
   mean += pixel
 mean //= width * height

 for j in range(_lowerCAmelCase  ):
  for i in range(_lowerCAmelCase  ):
   UpperCamelCase			:      Union[str, Any] 			=     255 if pixels[i, j] > mean else 0
 return image


if __name__ == "__main__":
    __lowerCamelCase :  Union[str, Any]										=  mean_threshold(Image.open("""path_to_image""").convert("""L"""))
    image.save("""output_image_path""")
