

import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_longformer import LongformerTokenizer


__A     						=      logging.get_logger(__name__)

__A     						=      {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

__A     						=      {
    '''vocab_file''': {
        '''allenai/longformer-base-4096''': '''https://huggingface.co/allenai/longformer-base-4096/resolve/main/vocab.json''',
        '''allenai/longformer-large-4096''': (
            '''https://huggingface.co/allenai/longformer-large-4096/resolve/main/vocab.json'''
        ),
        '''allenai/longformer-large-4096-finetuned-triviaqa''': (
            '''https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/vocab.json'''
        ),
        '''allenai/longformer-base-4096-extra.pos.embd.only''': (
            '''https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/vocab.json'''
        ),
        '''allenai/longformer-large-4096-extra.pos.embd.only''': (
            '''https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/vocab.json'''
        ),
    },
    '''merges_file''': {
        '''allenai/longformer-base-4096''': '''https://huggingface.co/allenai/longformer-base-4096/resolve/main/merges.txt''',
        '''allenai/longformer-large-4096''': (
            '''https://huggingface.co/allenai/longformer-large-4096/resolve/main/merges.txt'''
        ),
        '''allenai/longformer-large-4096-finetuned-triviaqa''': (
            '''https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/merges.txt'''
        ),
        '''allenai/longformer-base-4096-extra.pos.embd.only''': (
            '''https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/merges.txt'''
        ),
        '''allenai/longformer-large-4096-extra.pos.embd.only''': (
            '''https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/merges.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''allenai/longformer-base-4096''': (
            '''https://huggingface.co/allenai/longformer-base-4096/resolve/main/tokenizer.json'''
        ),
        '''allenai/longformer-large-4096''': (
            '''https://huggingface.co/allenai/longformer-large-4096/resolve/main/tokenizer.json'''
        ),
        '''allenai/longformer-large-4096-finetuned-triviaqa''': (
            '''https://huggingface.co/allenai/longformer-large-4096-finetuned-triviaqa/resolve/main/tokenizer.json'''
        ),
        '''allenai/longformer-base-4096-extra.pos.embd.only''': (
            '''https://huggingface.co/allenai/longformer-base-4096-extra.pos.embd.only/resolve/main/tokenizer.json'''
        ),
        '''allenai/longformer-large-4096-extra.pos.embd.only''': (
            '''https://huggingface.co/allenai/longformer-large-4096-extra.pos.embd.only/resolve/main/tokenizer.json'''
        ),
    },
}

__A     						=      {
    '''allenai/longformer-base-4096''': 40_96,
    '''allenai/longformer-large-4096''': 40_96,
    '''allenai/longformer-large-4096-finetuned-triviaqa''': 40_96,
    '''allenai/longformer-base-4096-extra.pos.embd.only''': 40_96,
    '''allenai/longformer-large-4096-extra.pos.embd.only''': 40_96,
}



class     lowercase_       (    __lowercase	):
      UpperCamelCase_     :						Dict		 =							VOCAB_FILES_NAMES
      UpperCamelCase_     :						str		 =							PRETRAINED_VOCAB_FILES_MAP
      UpperCamelCase_     :						int		 =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      UpperCamelCase_     :						Union[str, Any]		 =							["input_ids", "attention_mask"]
      UpperCamelCase_     :						Union[str, Any]		 =							LongformerTokenizer



      def __init__(     self :							List[Any]     ,   A__ :							Union[str, Any]=None     ,   A__ :							List[str]=None     ,   A__ :							int=None     ,   A__ :							Any="replace"     ,   A__ :							Any="<s>"     ,   A__ :							Tuple="</s>"     ,   A__ :							Optional[int]="</s>"     ,   A__ :							List[Any]="<s>"     ,   A__ :							Dict="<unk>"     ,   A__ :							List[str]="<pad>"     ,   A__ :							Dict="<mask>"     ,   A__ :							Optional[Any]=False     ,   A__ :							int=True     ,   **A__ :							List[Any]     ,   )       ->	Optional[int]:
        super().__init__(
            A__     ,   A__     ,   tokenizer_file=A__     ,   errors=A__     ,   bos_token=A__     ,   eos_token=A__     ,   sep_token=A__     ,   cls_token=A__     ,   unk_token=A__     ,   pad_token=A__     ,   mask_token=A__     ,   add_prefix_space=A__     ,   trim_offsets=A__     ,   **A__     ,   )

        _snake_case		=				json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()						)
        if pre_tok_state.get('''add_prefix_space'''     ,   A__						) != add_prefix_space:
          _snake_case		=				getattr(A__     ,   pre_tok_state.pop('''type'''						)						)
          _snake_case		=				add_prefix_space
          _snake_case		=				pre_tok_class(**A__						)

        _snake_case		=				add_prefix_space

        _snake_case		=				'''post_processor'''
        _snake_case		=				getattr(self.backend_tokenizer     ,   A__     ,   A__						)
        if tokenizer_component_instance:
          _snake_case		=				json.loads(tokenizer_component_instance.__getstate__()						)

          # The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
          if "sep" in state:
            _snake_case		=				tuple(state['''sep''']						)
          if "cls" in state:
            _snake_case		=				tuple(state['''cls''']						)

          _snake_case		=				False

          if state.get('''add_prefix_space'''     ,   A__						) != add_prefix_space:
            _snake_case		=				add_prefix_space
            _snake_case		=				True

          if state.get('''trim_offsets'''     ,   A__						) != trim_offsets:
            _snake_case		=				trim_offsets
            _snake_case		=				True

          if changes_to_apply:
            _snake_case		=				getattr(A__     ,   state.pop('''type'''						)						)
            _snake_case		=				component_class(**A__						)
            setattr(self.backend_tokenizer     ,   A__     ,   A__						)



      @property
      def 		UpperCamelCase_						(     self :							List[str]						)       ->	str:
        if self._mask_token is None:
          if self.verbose:
            logger.error('''Using mask_token, but it is not set yet.'''						)
          return None
        return str(self._mask_token						)



      @mask_token.setter
      def 		UpperCamelCase_						(     self :							Dict     ,   A__ :							Dict						)       ->	Union[str, Any]:
        _snake_case		=				AddedToken(A__     ,   lstrip=A__     ,   rstrip=A__						) if isinstance(A__     ,   A__						) else value
        _snake_case		=				value



      def 		UpperCamelCase_						(     self :							Optional[int]     ,   *A__ :							Dict     ,   **A__ :							List[str]						)       ->	BatchEncoding:
        _snake_case		=				kwargs.get('''is_split_into_words'''     ,   A__						)
        assert self.add_prefix_space or not is_split_into_words, (
            f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
            "to use it with pretokenized inputs."
        )

        return super()._batch_encode_plus(*A__     ,   **A__						)



      def 		UpperCamelCase_						(     self :							Union[str, Any]     ,   *A__ :							str     ,   **A__ :							Optional[int]						)       ->	BatchEncoding:
        _snake_case		=				kwargs.get('''is_split_into_words'''     ,   A__						)

        assert self.add_prefix_space or not is_split_into_words, (
            f"""You need to instantiate {self.__class__.__name__} with add_prefix_space=True """
            "to use it with pretokenized inputs."
        )

        return super()._encode_plus(*A__     ,   **A__						)



      def 		UpperCamelCase_						(     self :							List[str]     ,   A__ :							str     ,   A__ :							Optional[str] = None						)       ->	Tuple[str]:
        _snake_case		=				self._tokenizer.model.save(A__     ,   name=A__						)
        return tuple(A__						)



      def 		UpperCamelCase_						(     self :							Any     ,   A__ :							Dict     ,   A__ :							List[str]=None						)       ->	Any:
        _snake_case		=				[self.bos_token_id] + token_ids_a + [self.eos_token_id]
        if token_ids_a is None:
          return output

        return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]







      def 		UpperCamelCase_						(     self :							Optional[int]     ,   A__ :							List[int]     ,   A__ :							Optional[List[int]] = None						)       ->	List[int]:
        _snake_case		=				[self.sep_token_id]
        _snake_case		=				[self.cls_token_id]

        if token_ids_a is None:
          return len(cls + token_ids_a + sep						) * [0]
        return len(cls + token_ids_a + sep + sep + token_ids_a + sep						) * [0]




from __future__ import annotations

from collections import Counter



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



  """simple docstring"""






  _snake_case		=				[True] * n
  _snake_case		=				False
  _snake_case		=				False
  _snake_case		=				True

  for i in range(3					,			int(n**0.5 + 1	)					,			2	):
    _snake_case		=				i * 2
    while index < n:
      _snake_case		=				False
      _snake_case		=				index + i

  _snake_case		=				[2]

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

  return primes



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



  """simple docstring"""






  _snake_case		=				str(_UpperCamelCase	)
  _snake_case		=				[]
  _snake_case		=				['''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''']

  for duplicate in Counter(_UpperCamelCase	) - Counter(set(_UpperCamelCase	)	):
    _snake_case		=				[int(number_str.replace(_UpperCamelCase					,			_UpperCamelCase	)	) for digit in digits]
    replacements.append(_UpperCamelCase	)

  return replacements



def  snake_case_(_UpperCamelCase = 8	)				->      int:



  """simple docstring"""






  _snake_case		=				set()

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

  for prime in primes:
    if prime in numbers_checked:
      continue

    _snake_case		=				digit_replacements(_UpperCamelCase	)

    for family in replacements:
      numbers_checked.update(_UpperCamelCase	)
      _snake_case		=				primes.intersection(_UpperCamelCase	)

      if len(_UpperCamelCase	) != family_length:
        continue

      return min(_UpperCamelCase	)

  return -1


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

