'''simple docstring'''




from decimal import Decimal, getcontext
from math import ceil, factorial

def _UpperCamelCase   (       SCREAMING_SNAKE_CASE_							):

     if not isinstance(SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_							):
          raise TypeError('Undefined for non-integers'							)
     elif precision < 1:
          raise ValueError('Undefined for non-natural numbers'							)

     lowercase_					:       str     				=					precision
     lowercase_					:       List[str]     				=					ceil(precision / 14							)
     lowercase_					:       Union[str, Any]     				=					426_880 * Decimal(10_005							).sqrt()
     lowercase_					:       List[Any]     				=					1
     lowercase_					:       Optional[int]     				=					13_591_409
     lowercase_					:       Dict     				=					Decimal(SCREAMING_SNAKE_CASE_							)
     for k in range(1  ,       SCREAMING_SNAKE_CASE_							):
          lowercase_					:       List[str]     				=					factorial(6 * k							) // (factorial(3 * k							) * factorial(SCREAMING_SNAKE_CASE_							) ** 3)
          linear_term += 545_140_134
          exponential_term *= -262_537_412_640_768_000
          partial_sum += Decimal(multinomial_term * linear_term							) / exponential_term
     return str(constant_term / partial_sum							)[:-1]


if __name__ == "__main__":
 _A								=   5_0
 print(F"""The first {n} digits of pi is: {pi(n)}""")





'''simple docstring'''




import os

def _UpperCamelCase   (       SCREAMING_SNAKE_CASE_							):
     lowercase_					:       List[Any]     				=					len(grid[0]							)
     lowercase_					:       Union[str, Any]     				=					len(SCREAMING_SNAKE_CASE_							)

     lowercase_					:       Union[str, Any]     				=					0
     lowercase_					:       int     				=					0
     lowercase_					:       Union[str, Any]     				=					0

     # Check vertically, horizontally, diagonally at the same time (only works
     # for nxn grid)
     for i in range(SCREAMING_SNAKE_CASE_							):
          for j in range(n_rows - 3							):
               lowercase_					:       Dict     				=					grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
               lowercase_					:       Optional[Any]     				=					grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

               # Left-to-right diagonal (\) product
               if i < n_columns - 3:
                    lowercase_					:       Tuple     				=					(
                        grid[i][j]
                        * grid[i + 1][j + 1]
                        * grid[i + 2][j + 2]
                        * grid[i + 3][j + 3]
                    )

               # Right-to-left diagonal(/) product
               if i > 2:
                    lowercase_					:       int     				=					(
                        grid[i][j]
                        * grid[i - 1][j + 1]
                        * grid[i - 2][j + 2]
                        * grid[i - 3][j + 3]
                    )

               lowercase_					:       Optional[int]     				=					max(
                   SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_							)
               if max_product > largest:
                    lowercase_					:       List[Any]     				=					max_product

     return largest

def _UpperCamelCase   (       ):
     lowercase_					:       int     				=					[]
     with open(os.path.dirname(SCREAMING_SNAKE_CASE_							) + '/grid.txt'							) as file:
          for line in file:
               grid.append(line.strip('\n'							).split(' '							)							)

     lowercase_					:       Dict     				=					[[int(SCREAMING_SNAKE_CASE_							) for i in grid[j]] for j in range(len(SCREAMING_SNAKE_CASE_							)							)]

     return largest_product(SCREAMING_SNAKE_CASE_							)


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




