





import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


_UpperCAmelCase										=					datasets.utils.logging.get_logger(__name__)



@dataclass
class 				_UpperCamelCase       (						datasets.BuilderConfig  ):
       _UpperCamelCase					:       Optional[datasets.Features]       = None



class 				_UpperCamelCase       (						datasets.ArrowBasedBuilder  ):
       _UpperCamelCase					:       Union[str, Any]       = ArrowConfig

       def lowercase			(		self:			Optional[int]		)							->			Any:




              """simple docstring"""


              return datasets.DatasetInfo(features=self.config.features		)

       def lowercase			(		self:			List[Any]       , _SCREAMING_SNAKE_CASE:			List[str]		)							->			int:




              """simple docstring"""


              if not self.config.data_files:
                     raise ValueError(f'''At least one data file must be specified, but got data_files={self.config.data_files}'''		)
              UpperCamelCase_ 							=	dl_manager.download_and_extract(self.config.data_files		)
              if isinstance(_SCREAMING_SNAKE_CASE       , (str, list, tuple)		):
                     UpperCamelCase_ 							=	data_files
                     if isinstance(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE		):
                            UpperCamelCase_ 							=	[files]
                     # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
                     UpperCamelCase_ 							=	[dl_manager.iter_files(_SCREAMING_SNAKE_CASE		) for file in files]
                     return [datasets.SplitGenerator(name=datasets.Split.TRAIN       , gen_kwargs={"files": files}		)]
              UpperCamelCase_ 							=	[]
              for split_name, files in data_files.items():
                     if isinstance(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE		):
                            UpperCamelCase_ 							=	[files]
                     # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
                     UpperCamelCase_ 							=	[dl_manager.iter_files(_SCREAMING_SNAKE_CASE		) for file in files]
                     # Infer features is they are stoed in the arrow schema
                     if self.info.features is None:
                            for file in itertools.chain.from_iterable(_SCREAMING_SNAKE_CASE		):
                                   with open(_SCREAMING_SNAKE_CASE       , "rb"		) as f:
                                          UpperCamelCase_ 							=	datasets.Features.from_arrow_schema(pa.ipc.open_stream(_SCREAMING_SNAKE_CASE		).schema		)
                                   break
                     splits.append(datasets.SplitGenerator(name=_SCREAMING_SNAKE_CASE       , gen_kwargs={"files": files}		)		)
              return splits

       def lowercase			(		self:			Optional[int]       , _SCREAMING_SNAKE_CASE:			pa.Table		)							->			pa.Table:




              """simple docstring"""


              if self.info.features is not None:
                     # more expensive cast to support nested features with keys in a different order
                     # allows str <-> int/float or str to Audio for example
                     UpperCamelCase_ 							=	table_cast(_SCREAMING_SNAKE_CASE       , self.info.features.arrow_schema		)
              return pa_table



       def lowercase			(		self:			List[str]       , _SCREAMING_SNAKE_CASE:			Optional[int]		)							->			Dict:




              """simple docstring"""


              for file_idx, file in enumerate(itertools.chain.from_iterable(_SCREAMING_SNAKE_CASE		)		):
                     with open(_SCREAMING_SNAKE_CASE       , "rb"		) as f:
                            try:
                                   for batch_idx, record_batch in enumerate(pa.ipc.open_stream(_SCREAMING_SNAKE_CASE		)		):
                                          UpperCamelCase_ 							=	pa.Table.from_batches([record_batch]		)
                                          # Uncomment for debugging (will print the Arrow table size and elements)
                                          # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                                          # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                                          yield f'''{file_idx}_{batch_idx}''', self._cast_table(_SCREAMING_SNAKE_CASE		)
                            except ValueError as e:
                                   logger.error(f'''Failed to read file \'{file}\' with error {type(_SCREAMING_SNAKE_CASE		)}: {e}'''		)
                                   raise








from __future__ import annotations




def 			lowerCAmelCase_			(				UpperCamelCase_	)  ->		int | None:
       for r in range(1       ,		UpperCamelCase_	):
              UpperCamelCase_ 							=	[]
              for x in range(n - 1	):
                     UpperCamelCase_ 							=	pow(UpperCamelCase_       ,		UpperCamelCase_       ,		UpperCamelCase_	)
                     if val in li:
                            break
                     li.append(UpperCamelCase_	)
              else:
                     return r
       return None


if __name__ == "__main__":
     _UpperCAmelCase										=					int(input('Enter a prime number q: '))
     _UpperCAmelCase										=					find_primitive(q)
     if a is None:
          print(f'''Cannot find the primitive for the value: {a!r}''')
     else:
          _UpperCAmelCase										=					int(input('Enter private key of A: '))
          _UpperCAmelCase										=					pow(a, a_private, q)
          _UpperCAmelCase										=					int(input('Enter private key of B: '))
          _UpperCAmelCase										=					pow(a, b_private, q)

          _UpperCAmelCase										=					pow(b_public, a_private, q)
          _UpperCAmelCase										=					pow(a_public, b_private, q)

          print('The key value generated by A is: ', a_secret)
          print('The key value generated by B is: ', b_secret)

