
from collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  Dict:
    if is_torch_available():
        import torch

        if isinstance(_lowerCAmelCase		,   torch.Tensor		):
            return True

    return isinstance(_lowerCAmelCase		,   np.ndarray		)





class   __lowerCAmelCase		(		A__ ):



      """simple docstring"""







      def 						snake_case_     ( self						:    Union[str, Any]			):
          __lowercase						:     Optional[int]		      =    fields(self			)

          # Safety and consistency checks
          if not len(snake_case_			):
              raise ValueError(F'{self.__class__.__name__} has no fields.'			)

          __lowercase						:     Tuple		      =    getattr(self			,    class_fields[0].name			)
          __lowercase						:     int		      =    all(getattr(self			,    field.name			) is None for field in class_fields[1:]			)

          if other_fields_are_none and isinstance(snake_case_			,    snake_case_			):
              for key, value in first_field.items():
                  __lowercase						:     Tuple		      =    value
          else:
              for field in class_fields:
                  __lowercase						:     List[Any]		      =    getattr(self			,    field.name			)
                  if v is not None:
                      __lowercase						:     Optional[Any]		      =    v




      def __delitem__( self						:    List[Any]			,    *_snake_case						:    List[str]			,    **_snake_case						:    Tuple			):
          raise Exception(F'You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.'			)




      def 						snake_case_     ( self						:    int			,    *_snake_case						:    int			,    **_snake_case						:    Dict			):
          raise Exception(F'You cannot use ``setdefault`` on a {self.__class__.__name__} instance.'			)




      def 						snake_case_     ( self						:    Union[str, Any]			,    *_snake_case						:    Dict			,    **_snake_case						:    Tuple			):
          raise Exception(F'You cannot use ``pop`` on a {self.__class__.__name__} instance.'			)




      def 						snake_case_     ( self						:    List[str]			,    *_snake_case						:    Dict			,    **_snake_case						:    Optional[Any]			):
          raise Exception(F'You cannot use ``update`` on a {self.__class__.__name__} instance.'			)




      def __getitem__( self						:    Optional[int]			,    _snake_case						:    List[str]			):
          if isinstance(snake_case_			,    snake_case_			):
              __lowercase						:     Optional[int]		      =    dict(self.items()			)
              return inner_dict[k]
          else:
              return self.to_tuple()[k]




      def __setattr__( self						:    int			,    _snake_case						:    Optional[int]			,    _snake_case						:    str			):
          if name in self.keys() and value is not None:
              # Don't call self.__setitem__ to avoid recursion errors
              super().__setitem__(snake_case_			,    snake_case_			)
          super().__setattr__(snake_case_			,    snake_case_			)




      def __setitem__( self						:    Tuple			,    _snake_case						:    int			,    _snake_case						:    Optional[int]			):
          # Will raise a KeyException if needed
          super().__setitem__(snake_case_			,    snake_case_			)
          # Don't call self.__setattr__ to avoid recursion errors
          super().__setattr__(snake_case_			,    snake_case_			)




      def 						snake_case_     ( self						:    Union[str, Any]			):
          return tuple(self[k] for k in self.keys()			)




from __future__ import annotations

from collections import Counter


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  list[int]:
    __lowercase						:     Any		      =    [True] * n
    __lowercase						:     str		      =    False
    __lowercase						:     int		      =    False
    __lowercase						:     List[Any]		      =    True

    for i in range(3		,   int(n**0.5 + 1		)		,   2		):
        __lowercase						:     List[str]		      =    i * 2
        while index < n:
            __lowercase						:     List[Any]		      =    False
            __lowercase						:     Dict		      =    index + i

    __lowercase						:     Tuple		      =    [2]

    for i in range(3		,   __lowerCAmelCase		,   2		):
        if is_prime[i]:
            primes.append(__lowerCAmelCase		)

    return primes


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  list[list[int]]:
    __lowercase						:     Optional[int]		      =    str(__lowerCAmelCase		)
    __lowercase						:     List[str]		      =    []
    __lowercase						:     int		      =    ['''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''']

    for duplicate in Counter(__lowerCAmelCase		) - Counter(set(__lowerCAmelCase		)		):
        __lowercase						:     Union[str, Any]		      =    [int(number_str.replace(__lowerCAmelCase		,   __lowerCAmelCase		)		) for digit in digits]
        replacements.append(__lowerCAmelCase		)

    return replacements


def       UpperCAmelCase_					(  __lowerCAmelCase = 8		)	->  int:
    __lowercase						:     Tuple		      =    set()

    # Filter primes with less than 3 replaceable digits
    __lowercase						:     int		      =    {
        x for x in set(prime_sieve(1_000_000		)		) if len(str(__lowerCAmelCase		)		) - len(set(str(__lowerCAmelCase		)		)		) >= 3
    }

    for prime in primes:
        if prime in numbers_checked:
            continue

        __lowercase						:     str		      =    digit_replacements(__lowerCAmelCase		)

        for family in replacements:
            numbers_checked.update(__lowerCAmelCase		)
            __lowercase						:     List[Any]		      =    primes.intersection(__lowerCAmelCase		)

            if len(__lowerCAmelCase		) != family_length:
                continue

            return min(__lowerCAmelCase		)

    return -1


if __name__ == "__main__":
 print(solution())


