


"""simple docstring"""


def   snake_case		(     UpperCamelCase__       :						Any			,				UpperCamelCase__       :						Union[str, Any]    )   ->      Optional[int]:
      lowerCamelCase					:					Union[str, Any]        =	""""""
      for i in table:
            res += inp[i - 1]
      return res




def   snake_case		(     UpperCamelCase__       :						str    )   ->      Dict:
      return data[1:] + data[0]




def   snake_case		(     UpperCamelCase__       :						List[str]			,				UpperCamelCase__       :						Tuple    )   ->      List[Any]:
      lowerCamelCase					:					Union[str, Any]        =	""""""
      for i in range(len(UpperCamelCase__    )    ):
            if a[i] == b[i]:
                  res += "0"
            else:
                  res += "1"
      return res




def   snake_case		(     UpperCamelCase__       :						List[str]			,				UpperCamelCase__       :						Optional[int]    )   ->      Union[str, Any]:
      lowerCamelCase					:					Union[str, Any]        =	int("""0b""" + data[0] + data[-1]			,				2    )
      lowerCamelCase					:					Optional[int]        =	int("""0b""" + data[1:3]			,				2    )
      return bin(s[row][col]    )[2:]




def   snake_case		(     UpperCamelCase__       :						Dict			,				UpperCamelCase__       :						List[Any]			,				UpperCamelCase__       :						int			,				UpperCamelCase__       :						Tuple			,				UpperCamelCase__       :						str    )   ->      Union[str, Any]:
      lowerCamelCase					:					int        =	message[:4]
      lowerCamelCase					:					int        =	message[4:]
      lowerCamelCase					:					List[str]        =	apply_table(UpperCamelCase__			,				UpperCamelCase__    )
      lowerCamelCase					:					Tuple        =	xor(UpperCamelCase__			,				UpperCamelCase__    )
      lowerCamelCase					:					int        =	apply_sbox(UpperCamelCase__			,				temp[:4]    )  # noqa: E741
      lowerCamelCase					:					List[str]        =	apply_sbox(UpperCamelCase__			,				temp[4:]    )
      lowerCamelCase					:					str        =	"""0""" * (2 - len(UpperCamelCase__    )) + l  # noqa: E741
      lowerCamelCase					:					List[Any]        =	"""0""" * (2 - len(UpperCamelCase__    )) + r
      lowerCamelCase					:					Optional[Any]        =	apply_table(l + r			,				UpperCamelCase__    )
      lowerCamelCase					:					Dict        =	xor(UpperCamelCase__			,				UpperCamelCase__    )
      return temp + right


if __name__ == "__main__":
    __lowerCamelCase      :Dict	    =		input('Enter 10 bit key: ')
    __lowerCamelCase      :int	    =		input('Enter 8 bit message: ')

    __lowerCamelCase      :List[Any]	    =		[6, 3, 7, 4, 8, 5, 10, 9]
    __lowerCamelCase      :Any	    =		[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
    __lowerCamelCase      :List[str]	    =		[2, 4, 3, 1]
    __lowerCamelCase      :List[Any]	    =		[2, 6, 3, 1, 4, 8, 5, 7]
    __lowerCamelCase      :Tuple	    =		[4, 1, 3, 5, 7, 2, 8, 6]
    __lowerCamelCase      :str	    =		[4, 1, 2, 3, 2, 3, 4, 1]
    __lowerCamelCase      :List[str]	    =		[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
    __lowerCamelCase      :str	    =		[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

    # key generation
    __lowerCamelCase      :int	    =		apply_table(key, paa_table)
    __lowerCamelCase      :str	    =		temp[:5]
    __lowerCamelCase      :Tuple	    =		temp[5:]
    __lowerCamelCase      :Union[str, Any]	    =		left_shift(left)
    __lowerCamelCase      :List[str]	    =		left_shift(right)
    __lowerCamelCase      :Optional[Any]	    =		apply_table(left + right, pa_table)
    __lowerCamelCase      :str	    =		left_shift(left)
    __lowerCamelCase      :Optional[int]	    =		left_shift(right)
    __lowerCamelCase      :Union[str, Any]	    =		left_shift(left)
    __lowerCamelCase      :int	    =		left_shift(right)
    __lowerCamelCase      :Union[str, Any]	    =		apply_table(left + right, pa_table)

    # encryption
    __lowerCamelCase      :Union[str, Any]	    =		apply_table(message, IP)
    __lowerCamelCase      :Any	    =		function(expansion, sa, sa, keya, temp)
    __lowerCamelCase      :int	    =		temp[4:] + temp[:4]
    __lowerCamelCase      :List[str]	    =		function(expansion, sa, sa, keya, temp)
    __lowerCamelCase      :Tuple	    =		apply_table(temp, IP_inv)
    print('Cipher text is:', CT)

    # decryption
    __lowerCamelCase      :Union[str, Any]	    =		apply_table(CT, IP)
    __lowerCamelCase      :Union[str, Any]	    =		function(expansion, sa, sa, keya, temp)
    __lowerCamelCase      :int	    =		temp[4:] + temp[:4]
    __lowerCamelCase      :Optional[int]	    =		function(expansion, sa, sa, keya, temp)
    __lowerCamelCase      :List[str]	    =		apply_table(temp, IP_inv)
    print('Plain text after decypting is:', PT)








"""simple docstring"""


import os




def   snake_case		(     )   ->      Optional[Any]:
      with open(os.path.dirname(UpperCamelCase__    ) + """/grid.txt"""    ) as f:
            lowerCamelCase					:					int        =	[]  # noqa: E741
            for _ in range(20    ):
                  l.append([int(UpperCamelCase__    ) for x in f.readline().split()]    )

            lowerCamelCase					:					Union[str, Any]        =	0

            # right
            for i in range(20    ):
                  for j in range(17    ):
                        lowerCamelCase					:					Dict        =	l[i][j] * l[i][j + 1] * l[i][j + 2] * l[i][j + 3]
                        if temp > maximum:
                              lowerCamelCase					:					Tuple        =	temp

        # down
            for i in range(17    ):
                  for j in range(20    ):
                        lowerCamelCase					:					Any        =	l[i][j] * l[i + 1][j] * l[i + 2][j] * l[i + 3][j]
                        if temp > maximum:
                              lowerCamelCase					:					Optional[Any]        =	temp

        # diagonal 1
            for i in range(17    ):
                  for j in range(17    ):
                        lowerCamelCase					:					List[Any]        =	l[i][j] * l[i + 1][j + 1] * l[i + 2][j + 2] * l[i + 3][j + 3]
                        if temp > maximum:
                              lowerCamelCase					:					List[str]        =	temp

        # diagonal 2
            for i in range(17    ):
                  for j in range(3			,				20    ):
                        lowerCamelCase					:					List[str]        =	l[i][j] * l[i + 1][j - 1] * l[i + 2][j - 2] * l[i + 3][j - 3]
                        if temp > maximum:
                              lowerCamelCase					:					List[Any]        =	temp
            return maximum


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




