

'''simple docstring'''

import random
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
				import torch

if is_vision_available():
				import PIL

				from transformers import FlavaImageProcessor
				from transformers.image_utils import PILImageResampling
				from transformers.models.flava.image_processing_flava import (
				    FLAVA_CODEBOOK_MEAN,
				    FLAVA_CODEBOOK_STD,
				    FLAVA_IMAGE_MEAN,
				    FLAVA_IMAGE_STD,
				)
else:
				a       :      Optional[Any]  	=			None







class   UpperCamelCase__   (       unittest.TestCase       ):


		"""simple docstring"""

		def __init__(			self   ,      snake_case   ,      snake_case=7   ,      snake_case=3   ,      snake_case=3_0   ,      snake_case=4_0_0   ,      snake_case=True   ,      snake_case=None   ,      snake_case=True   ,      snake_case=None   ,      snake_case=None   ,      snake_case=True   ,      snake_case=1 / 2_5_5   ,      snake_case=True   ,      snake_case=FLAVA_IMAGE_MEAN   ,      snake_case=FLAVA_IMAGE_STD   ,      snake_case=1_4   ,      snake_case=7_5   ,      snake_case=None   ,      snake_case=1_6   ,      snake_case=0.3   ,      snake_case=None   ,      snake_case=True   ,      snake_case=None   ,      snake_case=None   ,      snake_case=True   ,      snake_case=None   ,      snake_case=True   ,      snake_case=True   ,      snake_case=FLAVA_CODEBOOK_MEAN   ,      snake_case=FLAVA_CODEBOOK_STD   ,      ):


							'''simple docstring'''

							UpperCAmelCase		:							List[str]        =       size if size is not None else {"height": 2_2_4, "width": 2_2_4}
							UpperCAmelCase		:							Union[str, Any]        =       crop_size if crop_size is not None else {"height": 2_2_4, "width": 2_2_4}
							UpperCAmelCase		:							List[str]        =       codebook_size if codebook_size is not None else {"height": 1_1_2, "width": 1_1_2}
							UpperCAmelCase		:							int        =       codebook_crop_size if codebook_crop_size is not None else {"height": 1_1_2, "width": 1_1_2}

							UpperCAmelCase		:							Tuple        =       parent
							UpperCAmelCase		:							Union[str, Any]        =       batch_size
							UpperCAmelCase		:							List[Any]        =       num_channels
							UpperCAmelCase		:							List[str]        =       do_resize
							UpperCAmelCase		:							Any        =       do_rescale
							UpperCAmelCase		:							Dict        =       rescale_factor
							UpperCAmelCase		:							List[Any]        =       min_resolution
							UpperCAmelCase		:							List[str]        =       max_resolution
							UpperCAmelCase		:							int        =       size
							UpperCAmelCase		:							Optional[int]        =       resample if resample is not None else PILImageResampling.BICUBIC
							UpperCAmelCase		:							Any        =       do_normalize
							UpperCAmelCase		:							List[str]        =       image_mean
							UpperCAmelCase		:							List[Any]        =       image_std
							UpperCAmelCase		:							int        =       do_center_crop
							UpperCAmelCase		:							Tuple        =       crop_size

							UpperCAmelCase		:							str        =       input_size_patches
							UpperCAmelCase		:							Any        =       total_mask_patches
							UpperCAmelCase		:							str        =       mask_group_max_patches
							UpperCAmelCase		:							List[Any]        =       mask_group_min_patches
							UpperCAmelCase		:							str        =       mask_group_min_aspect_ratio
							UpperCAmelCase		:							Tuple        =       mask_group_max_aspect_ratio

							UpperCAmelCase		:							str        =       codebook_do_resize
							UpperCAmelCase		:							Optional[Any]        =       codebook_size
							UpperCAmelCase		:							Optional[Any]        =       codebook_resample if codebook_resample is not None else PILImageResampling.LANCZOS
							UpperCAmelCase		:							List[str]        =       codebook_do_center_crop
							UpperCAmelCase		:							int        =       codebook_crop_size
							UpperCAmelCase		:							Dict        =       codebook_do_map_pixels
							UpperCAmelCase		:							List[str]        =       codebook_do_normalize
							UpperCAmelCase		:							Tuple        =       codebook_image_mean
							UpperCAmelCase		:							int        =       codebook_image_std







		def 				A_	(			self      ):


							'''simple docstring'''

							return {
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_normalize": self.do_normalize,
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "resample": self.resample,
							    "do_rescale": self.do_rescale,
							    "rescale_factor": self.rescale_factor,
							    "do_center_crop": self.do_center_crop,
							    "crop_size": self.crop_size,
							    "input_size_patches": self.input_size_patches,
							    "total_mask_patches": self.total_mask_patches,
							    "mask_group_max_patches": self.mask_group_max_patches,
							    "mask_group_min_patches": self.mask_group_min_patches,
							    "mask_group_min_aspect_ratio": self.mask_group_min_aspect_ratio,
							    "mask_group_max_aspect_ratio": self.mask_group_min_aspect_ratio,
							    "codebook_do_resize": self.codebook_do_resize,
							    "codebook_size": self.codebook_size,
							    "codebook_resample": self.codebook_resample,
							    "codebook_do_center_crop": self.codebook_do_center_crop,
							    "codebook_crop_size": self.codebook_crop_size,
							    "codebook_do_map_pixels": self.codebook_do_map_pixels,
							    "codebook_do_normalize": self.codebook_do_normalize,
							    "codebook_image_mean": self.codebook_image_mean,
							    "codebook_image_std": self.codebook_image_std,
							}







		def 				A_	(			self      ):


							'''simple docstring'''

							return (self.size["height"], self.size["width"])







		def 				A_	(			self      ):


							'''simple docstring'''

							return (
							    (self.input_size_patches, self.input_size_patches)
							    if not isinstance(self.input_size_patches   ,      snake_case      )
							    else self.input_size_patches
							)







		def 				A_	(			self      ):


							'''simple docstring'''

							return (self.codebook_size["height"], self.codebook_size["width"])







@require_torch
@require_vision
class   UpperCamelCase__   (       lowercase__							,							unittest.TestCase       ):


		"""simple docstring"""

		SCREAMING_SNAKE_CASE__  :     Optional[int]       =							FlavaImageProcessor if is_vision_available() else None
		SCREAMING_SNAKE_CASE__  :     Any       =							None







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							Tuple        =       FlavaImageProcessingTester(self      )







		@property
		def 				A_	(			self      ):


							'''simple docstring'''

							return self.image_processor_tester.prepare_image_processor_dict()







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							Union[str, Any]        =       self.image_processing_class(**self.image_processor_dict      )
							self.assertTrue(hasattr(snake_case   ,      "image_mean"      )      )
							self.assertTrue(hasattr(snake_case   ,      "image_std"      )      )
							self.assertTrue(hasattr(snake_case   ,      "do_normalize"      )      )
							self.assertTrue(hasattr(snake_case   ,      "do_resize"      )      )
							self.assertTrue(hasattr(snake_case   ,      "resample"      )      )
							self.assertTrue(hasattr(snake_case   ,      "crop_size"      )      )
							self.assertTrue(hasattr(snake_case   ,      "do_center_crop"      )      )
							self.assertTrue(hasattr(snake_case   ,      "do_rescale"      )      )
							self.assertTrue(hasattr(snake_case   ,      "rescale_factor"      )      )
							self.assertTrue(hasattr(snake_case   ,      "masking_generator"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_do_resize"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_size"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_resample"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_do_center_crop"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_crop_size"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_do_map_pixels"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_do_normalize"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_image_mean"      )      )
							self.assertTrue(hasattr(snake_case   ,      "codebook_image_std"      )      )







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							List[str]        =       self.image_processing_class.from_dict(self.image_processor_dict      )
							self.assertEqual(image_processor.size   ,      {"height": 2_2_4, "width": 2_2_4}      )
							self.assertEqual(image_processor.crop_size   ,      {"height": 2_2_4, "width": 2_2_4}      )
							self.assertEqual(image_processor.codebook_size   ,      {"height": 1_1_2, "width": 1_1_2}      )
							self.assertEqual(image_processor.codebook_crop_size   ,      {"height": 1_1_2, "width": 1_1_2}      )

							UpperCAmelCase		:							Tuple        =       self.image_processing_class.from_dict(
							    self.image_processor_dict   ,      size=4_2   ,      crop_size=8_4   ,      codebook_size=3_3   ,      codebook_crop_size=6_6      )
							self.assertEqual(image_processor.size   ,      {"height": 4_2, "width": 4_2}      )
							self.assertEqual(image_processor.crop_size   ,      {"height": 8_4, "width": 8_4}      )
							self.assertEqual(image_processor.codebook_size   ,      {"height": 3_3, "width": 3_3}      )
							self.assertEqual(image_processor.codebook_crop_size   ,      {"height": 6_6, "width": 6_6}      )







		def 				A_	(			self      ):


							'''simple docstring'''

							pass







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							str        =       self.image_processing_class(**self.image_processor_dict      )
							# create random PIL images
							UpperCAmelCase		:							int        =       prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=snake_case      )
							for image in image_inputs:
												self.assertIsInstance(snake_case   ,      PIL.Image.Image      )

							# Test not batched input
							UpperCAmelCase		:							Optional[int]        =       image_processing(image_inputs[0]   ,      return_tensors="pt"      )

							# Test no bool masked pos
							self.assertFalse("bool_masked_pos" in encoded_images      )

							UpperCAmelCase ,			UpperCAmelCase		:							int        =       self.image_processor_tester.get_expected_image_size()

							self.assertEqual(
							    encoded_images.pixel_values.shape   ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,      )

							# Test batched
							UpperCAmelCase		:							Union[str, Any]        =       image_processing(snake_case   ,      return_tensors="pt"      )
							UpperCAmelCase ,			UpperCAmelCase		:							Optional[int]        =       self.image_processor_tester.get_expected_image_size()

							# Test no bool masked pos
							self.assertFalse("bool_masked_pos" in encoded_images      )

							self.assertEqual(
							    encoded_images.pixel_values.shape   ,      (
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        expected_height,
							        expected_width,
							    )   ,      )







		def 				A_	(			self   ,      snake_case   ,      snake_case      ):


							'''simple docstring'''

							UpperCAmelCase		:							List[str]        =       self.image_processing_class(**self.image_processor_dict      )
							# create random tensors
							UpperCAmelCase		:							Optional[int]        =       prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=snake_case   ,      **snake_case      )
							for image in image_inputs:
												self.assertIsInstance(snake_case   ,      snake_case      )

							# Test not batched input
							UpperCAmelCase		:							Optional[Any]        =       image_processing(image_inputs[0]   ,      return_tensors="pt"      )

							UpperCAmelCase ,			UpperCAmelCase		:							Union[str, Any]        =       self.image_processor_tester.get_expected_image_size()
							self.assertEqual(
							    encoded_images.pixel_values.shape   ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,      )

							UpperCAmelCase		:							Dict        =       image_processing(snake_case   ,      return_image_mask=snake_case   ,      return_tensors="pt"      )

							UpperCAmelCase ,			UpperCAmelCase		:							List[str]        =       self.image_processor_tester.get_expected_image_size()
							self.assertEqual(
							    encoded_images.pixel_values.shape   ,      (
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        expected_height,
							        expected_width,
							    )   ,      )

							UpperCAmelCase ,			UpperCAmelCase		:							Optional[int]        =       self.image_processor_tester.get_expected_mask_size()
							self.assertEqual(
							    encoded_images.bool_masked_pos.shape   ,      (
							        self.image_processor_tester.batch_size,
							        expected_height,
							        expected_width,
							    )   ,      )

							# Test batched
							UpperCAmelCase		:							List[str]        =       image_processing(snake_case   ,      return_tensors="pt"      ).pixel_values

							UpperCAmelCase ,			UpperCAmelCase		:							List[Any]        =       self.image_processor_tester.get_expected_image_size()
							self.assertEqual(
							    encoded_images.shape   ,      (
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        expected_height,
							        expected_width,
							    )   ,      )

							# Test masking
							UpperCAmelCase		:							Optional[Any]        =       image_processing(snake_case   ,      return_image_mask=snake_case   ,      return_tensors="pt"      )

							UpperCAmelCase ,			UpperCAmelCase		:							Union[str, Any]        =       self.image_processor_tester.get_expected_image_size()
							self.assertEqual(
							    encoded_images.pixel_values.shape   ,      (
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        expected_height,
							        expected_width,
							    )   ,      )

							UpperCAmelCase ,			UpperCAmelCase		:							str        =       self.image_processor_tester.get_expected_mask_size()
							self.assertEqual(
							    encoded_images.bool_masked_pos.shape   ,      (
							        self.image_processor_tester.batch_size,
							        expected_height,
							        expected_width,
							    )   ,      )







		def 				A_	(			self      ):


							'''simple docstring'''

							self._test_call_framework(np.ndarray   ,      prepare_kwargs={"numpify": True}      )







		def 				A_	(			self      ):


							'''simple docstring'''

							self._test_call_framework(torch.Tensor   ,      prepare_kwargs={"torchify": True}      )







		def 				A_	(			self      ):


							'''simple docstring'''

							random.seed(1_2_3_4      )
							UpperCAmelCase		:							Dict        =       self.image_processing_class(**self.image_processor_dict      )
							UpperCAmelCase		:							Any        =       prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=snake_case   ,      torchify=snake_case      )

							# Test not batched input
							UpperCAmelCase		:							str        =       image_processing(image_inputs[0]   ,      return_image_mask=snake_case   ,      return_tensors="pt"      )
							self.assertEqual(encoded_images.bool_masked_pos.sum().item()   ,      7_5      )







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							Optional[int]        =       self.image_processing_class(**self.image_processor_dict      )
							# create random PIL images
							UpperCAmelCase		:							Any        =       prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=snake_case      )
							for image in image_inputs:
												self.assertIsInstance(snake_case   ,      PIL.Image.Image      )

							# Test not batched input
							UpperCAmelCase		:							Union[str, Any]        =       image_processing(image_inputs[0]   ,      return_codebook_pixels=snake_case   ,      return_tensors="pt"      )
							UpperCAmelCase ,			UpperCAmelCase		:							Optional[int]        =       self.image_processor_tester.get_expected_codebook_image_size()
							self.assertEqual(
							    encoded_images.codebook_pixel_values.shape   ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,      )

							# Test batched
							UpperCAmelCase		:							List[str]        =       image_processing(snake_case   ,      return_codebook_pixels=snake_case   ,      return_tensors="pt"      )
							UpperCAmelCase ,			UpperCAmelCase		:							Tuple        =       self.image_processor_tester.get_expected_codebook_image_size()
							self.assertEqual(
							    encoded_images.codebook_pixel_values.shape   ,      (
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        expected_height,
							        expected_width,
							    )   ,      )



'''simple docstring'''

from __future__ import annotations







class   UpperCamelCase__   :


		"""simple docstring"""

		def __init__(			self   ,      snake_case      ):


							'''simple docstring'''

							UpperCAmelCase		:							str        =       data
							UpperCAmelCase		:							Dict        =       None







class   UpperCamelCase__   :


		"""simple docstring"""

		def __init__(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							str        =       None







		def 				A_	(			self   ,      snake_case      ):


							'''simple docstring'''

							UpperCAmelCase		:							int        =       Node(snake_case      )
							UpperCAmelCase		:							Optional[int]        =       self.head
							UpperCAmelCase		:							Union[str, Any]        =       new_node
							return self.head.data







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							Dict        =       self.head
							UpperCAmelCase		:							str        =       self.head
							if self.head:
												while fast_pointer and fast_pointer.next:
																	UpperCAmelCase		:							List[str]        =       fast_pointer.next.next
																	UpperCAmelCase		:							Any        =       slow_pointer.next
												return slow_pointer.data
							else:
												print("No element found."      )
												return None


if __name__ == "__main__":
				a       :      List[str]  	=			LinkedList()
				for _ in range(int(input().strip())):
								a       :      str  	=			int(input().strip())
								link.push(data)
				print(link.middle_element())
