This page is still under construction.

Parts of this page are still being built. What you see may change.

Unified State Exam

Interview

Time limit2sMemory limit512 MB

Summary
Convert an integer x into base -2, printing the number of digits and the binary digits from least significant to most.
Level

Medium5 of 10

Topics
Math, Number theory, Implementation, Greedy
Solved
No attempts yet

Problem

Sonya is a high school senior, and this year she has to take the Unified State Exam in computer science. She decided to start preparing early and began solving problems from past years' exams.

Many tasks require converting a number from one numeral system to another. Sonya handles such tasks with ease, but recently she came across a problem in one of the exams that seemed quite interesting: the number xx, given in decimal, has to be converted to the (−2-2)-base numeral system.

Formally, the representation of a number in the (−2-2)-base numeral system is a sequence of numbers a0,a1,…,an−1a_0, a_1, \ldots, a_{n-1}, each of which is 0 or 1, where n=1n = 1 or an−1≠0a_{n-1} \ne 0, and the following equality holds: x=∑i=0n−1ai(−2)i.x=\sum_{i=0}^{n-1} a_i (-2)^i.

For example, 3 in the (−2-2)-base numeral system is represented by the sequence (1,1,1)(1, 1, 1): indeed, 1⋅(−2)0+1⋅(−2)1+1⋅(−2)2=1−2+4=31\cdot(-2)^0+1\cdot(-2)^1+1\cdot(-2)^2=1-2+4=3.

The problem asks to convert only one number to the (−2-2)-base numeral system, but Sonya became curious about the solution to this problem in the general case.

After long deliberation, she turned to you for help. Help her convert the given number to the (−2-2)-base numeral system.

Input

The single line of the input file contains one integer xx, the number Sonya wants to represent in the (−2-2)-base numeral system (−1018≤x≤1018-10^{18} \le x \le 10^{18}).

Output

In the first line of the output file, print the number nn (n≥1n \ge 1).

In the second line of the output file, print nn numbers a0,a1,…,an−1a_0, a_1, \ldots, a_{n-1} separated by spaces, the digits of the number xx in the (−2-2)-base numeral system (0≤ai≤10 \le a_i \le 1).

If several answers exist, print any of them.

Examples2

  1. Example 1

    Input
    3
    
    Expected output
    3
    1 1 1
    
  2. Example 2

    Input
    -2
    
    Expected output
    2
    0 1