cho.sh
Notes
Loading...

Password

Time limit

1s

Memory limit

128 MB

Problem

A security company wants to make two integers for a password from one positive integer A.

Let x be the number of 1 bits in the binary representation of A. Find the following two integers.

  1. The closest integer smaller than A whose binary representation has exactly x one bits
  2. The closest integer greater than A whose binary representation has exactly x one bits

Write a program that finds and prints these two integers.

Input

The first line contains one positive integer A.

1 <= A <= 10^18

Output

Print two integers separated by a space: first the closest smaller integer satisfying the condition, then the closest greater integer satisfying the condition.

If no such integer exists on one side, print 0 in that position.