This page is still under construction.

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

Fractals

Time limit1sMemory limit128 MB

Summary
Draw a level-`level` block fractal of given width from (0,1) to (width,1) and list, in order, every integer y where the vertical line x meets a segment.
Level

Medium6 of 10

Topics
Recursion, Implementation, Simulation, Geometry
Solved
No attempts yet

Problem

A fractal is a geometric shape whose overall pattern repeats itself, identical to the whole, within each of its parts. Consider the simple "block fractal" described below. At every stage of the fractal's growth, each line segment in the fractal is divided into three equal parts. The first and last parts stay straight, but the middle part is replaced by a square "bump" whose height equals the width of that middle part. (You must consider the four orientations a segment can take. Depending on the direction of the segment currently being drawn, the bump may protrude up, down, left, or right.)

Draw this fractal on a Cartesian plane with (0,0)(0, 0) at the bottom-left corner. The fractal's bottom-left endpoint is at (0,1)(0, 1) and its bottom-right endpoint is at (width,1)(\text{width}, 1). For example, in a level 33 fractal of width 2727, the highest part is the segment from (13,14)(13, 14) to (14,14)(14, 14).

Write a program that tracks the integer coordinate points crossed by the segments of a "block fractal" whose bottom-left corner is at (0,1)(0, 1). Given the vertical line xx, report every integer yy where that line meets a segment of the fractal.

You may draw the fractal for debugging or interest, but some fractals may be too large to fit on one screen.

Input

One line with three integers: the level level\text{level}, the width width\text{width}, and the x-coordinate xx, separated by spaces. The width is a power of 33 and is large enough that every corner of the fractal lands on an integer lattice point (that is, width\text{width} is a multiple of 3level3^{\text{level}}). The width never exceeds 8181. The value xx is an integer with 0≤x≤width0 \le x \le \text{width}.

Output

Print, on one line, every integer yy for which the point (x,y)(x, y) lies on a segment of the fractal, sorted in ascending order and separated by single spaces.

Examples4

  1. Example 1

    Input
    3 27 5
    
    Expected output
    4 5 6
    
  2. Example 2

    Input
    3 27 18
    
    Expected output
    1 2 3 4 7 8 9 10
    
  3. Example 3

    Input
    2 27 19
    
    Expected output
    1 4 7
    
  4. Example 4

    Input
    4 81 38
    
    Expected output
    37 38 39