


'''simple docstring'''







from collections.abc import Generator
from math import sin






def 				lowerCAmelCase__	(    lowerCamelCase					:      bytes       ):
       if len(lowerCamelCase       ) != 32:
              raise ValueError('Input must be of length 32'       )

       _A					:     Union[str, Any]     = b''
       for i in [3, 2, 1, 0]:
              little_endian += string_aa[8 * i : 8 * i + 8]
       return little_endian






def 				lowerCAmelCase__	(    lowerCamelCase					:      int       ):
       if i < 0:
              raise ValueError('Input must be non-negative'       )

       _A					:     List[Any]     = format(lowerCamelCase  ,'08x'       )[-8:]
       _A					:     Optional[Any]     = b''
       for i in [3, 2, 1, 0]:
              little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('utf-8'       )
       return little_endian_hex






def 				lowerCAmelCase__	(    lowerCamelCase					:      bytes       ):
       _A					:     int     = b''
       for char in message:
              bit_string += format(lowerCamelCase  ,'08b'       ).encode('utf-8'       )
       _A					:     Optional[Any]     = format(len(lowerCamelCase       )  ,'064b'       ).encode('utf-8'       )

       # Pad bit_string to a multiple of 512 chars
       bit_string += b"1"
       while len(lowerCamelCase       ) % 512 != 448:
              bit_string += b"0"
       bit_string += to_little_endian(start_len[32:]       ) + to_little_endian(start_len[:32]       )

       return bit_string






def 				lowerCAmelCase__	(    lowerCamelCase					:      bytes       ):
       if len(lowerCamelCase       ) % 512 != 0:
              raise ValueError('Input must have length that\'s a multiple of 512'       )

       for pos in range(0  ,len(lowerCamelCase       )  ,512       ):
              _A					:     str     = bit_string[pos : pos + 512]
              _A					:     Tuple     = []
              for i in range(0  ,512  ,32       ):
                     block_words.append(int(to_little_endian(block[i : i + 32]       )  ,2       )       )
              yield block_words






def 				lowerCAmelCase__	(    lowerCamelCase					:      int       ):
       if i < 0:
              raise ValueError('Input must be non-negative'       )

       _A					:     Tuple     = format(lowerCamelCase  ,'032b'       )
       _A					:     int     = ''
       for c in i_str:
              new_str += "1" if c == "0" else "0"
       return int(lowerCamelCase  ,2       )






def 				lowerCAmelCase__	(    lowerCamelCase					:      int  ,lowerCamelCase					:      int       ):
       return (a + b) % 2**32






def 				lowerCAmelCase__	(    lowerCamelCase					:      int  ,lowerCamelCase					:      int       ):
       if i < 0:
              raise ValueError('Input must be non-negative'       )
       if shift < 0:
              raise ValueError('Shift must be non-negative'       )
       return ((i << shift) ^ (i >> (32 - shift))) % 2**32






def 				lowerCAmelCase__	(    lowerCamelCase					:      bytes       ):
       _A					:     Dict     = preprocess(lowerCamelCase       )

       _A					:     Dict     = [int(2**32 * abs(sin(i + 1       )       )       ) for i in range(64       )]

       # Starting states
       _A					:     int     = 0X67_452_301
       _A					:     Dict     = 0Xef_cda_b89
       _A					:     Optional[Any]     = 0X98_bad_cfe
       _A					:     List[Any]     = 0X10_325_476

       _A					:     Union[str, Any]     = [
           7,
           12,
           17,
           22,
           7,
           12,
           17,
           22,
           7,
           12,
           17,
           22,
           7,
           12,
           17,
           22,
           5,
           9,
           14,
           20,
           5,
           9,
           14,
           20,
           5,
           9,
           14,
           20,
           5,
           9,
           14,
           20,
           4,
           11,
           16,
           23,
           4,
           11,
           16,
           23,
           4,
           11,
           16,
           23,
           4,
           11,
           16,
           23,
           6,
           10,
           15,
           21,
           6,
           10,
           15,
           21,
           6,
           10,
           15,
           21,
           6,
           10,
           15,
           21,
       ]

       # Process bit string in chunks, each with 16 32-char words
       for block_words in get_block_words(lowerCamelCase       ):
              _A					:     List[str]     = aa
              _A					:     str     = ba
              _A					:     Optional[int]     = ca
              _A					:     int     = da

              # Hash current chunk
              for i in range(64       ):
                     if i <= 15:
                            # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
                            _A					:     Optional[Any]     = d ^ (b & (c ^ d))
                            _A					:     Dict     = i
                     elif i <= 31:
                            # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
                            _A					:     Tuple     = c ^ (d & (b ^ c))
                            _A					:     str     = (5 * i + 1) % 16
                     elif i <= 47:
                            _A					:     Tuple     = b ^ c ^ d
                            _A					:     List[Any]     = (3 * i + 5) % 16
                     else:
                            _A					:     Tuple     = c ^ (b | not_aa(lowerCamelCase       ))
                            _A					:     Optional[Any]     = (7 * i) % 16
                     _A					:     Optional[int]     = (f + a + added_consts[i] + block_words[g]) % 2**32
                     _A					:     int     = d
                     _A					:     Optional[Any]     = c
                     _A					:     Optional[int]     = b
                     _A					:     Union[str, Any]     = sum_aa(lowerCamelCase  ,left_rotate_aa(lowerCamelCase  ,shift_amounts[i]       )       )

              # Add hashed chunk to running total
              _A					:     Optional[Any]     = sum_aa(lowerCamelCase  ,lowerCamelCase       )
              _A					:     Optional[Any]     = sum_aa(lowerCamelCase  ,lowerCamelCase       )
              _A					:     Optional[Any]     = sum_aa(lowerCamelCase  ,lowerCamelCase       )
              _A					:     int     = sum_aa(lowerCamelCase  ,lowerCamelCase       )

       _A					:     str     = reformat_hex(lowerCamelCase       ) + reformat_hex(lowerCamelCase       ) + reformat_hex(lowerCamelCase       ) + reformat_hex(lowerCamelCase       )
       return digest


if __name__ == "__main__":
   import doctest

   doctest.testmod()










'''simple docstring'''







class 			__lowerCamelCase			:  # Public class to implement a graph
    """simple docstring"""


    def __init__(  self      :							Optional[Any]				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							list[list[bool]]):
           _A					:     List[Any]     = row
           _A					:     Union[str, Any]     = col
           _A					:     List[str]     = graph


    def        A   (  self      :							Any				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							list[list[bool]]):
           return (
               0 <= i < self.ROW
               and 0 <= j < self.COL
               and not visited[i][j]
               and self.graph[i][j]
           )


    def        A   (  self      :							Tuple				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							int				,							SCREAMING_SNAKE_CASE      :							list[list[bool]]):
           # Checking all 8 elements surrounding nth element
           _A					:     Tuple     = [-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
           _A					:     Dict     = [-1, 0, 1, -1, 1, -1, 0, 1]
           _A					:     List[Any]     = True  # Make those cells visited
           for k in range(8):
                  if self.is_safe(i + row_nbr[k]				,							j + col_nbr[k]				,							SCREAMING_SNAKE_CASE):
                         self.diffs(i + row_nbr[k]				,							j + col_nbr[k]				,							SCREAMING_SNAKE_CASE)


    def        A   (  self      :							int):  # And finally, count all islands.
           _A					:     Dict     = [[False for j in range(self.COL)] for i in range(self.ROW)]
           _A					:     Union[str, Any]     = 0
           for i in range(self.ROW):
                  for j in range(self.COL):
                         if visited[i][j] is False and self.graph[i][j] == 1:
                                self.diffs(SCREAMING_SNAKE_CASE				,							SCREAMING_SNAKE_CASE				,							SCREAMING_SNAKE_CASE)
                                count += 1
           return count






