#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>

#define MPI         (3.141592653589793)
#define STR_SIZE    (2)
#define SUCCESS     (0)
#define FAILURE     (-1)
#define rad(x)      (x * MPI / 180)

typedef enum
{
    LINE_FEED,
    BLANK,
    DELIMITER_ERROR
}DELIMITER_INFO;

typedef struct 
{
    double x;
    double y;
}POINT;

void Print_Kock_Curve(int n, POINT p1, POINT p2);
DELIMITER_INFO get_int(int *num, int min, int max);
DELIMITER_INFO get_str(char *p_str, int min, int max);
int judge_constraint(int test_num, int min, int max);


int main(void)
{
    int num;
    POINT p1 = {0,0}, p2 = {100,0};
    
    if(get_int(&num, 0, 6) != LINE_FEED)
    {
        return FAILURE;
    }
    
    printf("%.8lf %.8lf\n", p1.x, p1.y);
    Print_Kock_Curve(num, p1, p2);
    printf("%.8lf %.8lf\n", p2.x, p2.y);
    
    return SUCCESS;
}

void Print_Kock_Curve(int n, POINT p1, POINT p2)
{
    POINT s, t, u;
    
    if(n == 0)
    {
        return;
    }
    
    
    
    s.x = (2 * p1.x + 1 * p2.x) / 3;
    s.y = (2 * p1.y + 1 * p2.y) / 3;
    t.x = (1 * p1.x + 2 * p2.x) / 3;
    t.y = (1 * p1.y + 2 * p2.y) / 3;
    u.x = (t.x - s.x) * cos(rad(60)) - (t.y - s.y) * sin(rad(60)) + s.x;
    u.y = (t.x - s.x) * sin(rad(60)) - (t.y - s.y) * cos(rad(60)) + s.y;
    

    Print_Kock_Curve(n - 1, p1, s);
    printf("%.8lf %.8lf\n", s.x, s.y);
    Print_Kock_Curve(n - 1, s, u);
    printf("%.8lf %.8lf\n", u.x, u.y);
    Print_Kock_Curve(n - 1, u, t);
    printf("%.8lf %.8lf\n", t.x, t.y);
    Print_Kock_Curve(n - 1, t, p2);
    
    return;
}

DELIMITER_INFO get_int(int *num, int min, int max)
{
    char str[STR_SIZE];
    DELIMITER_INFO delimiter;
    unsigned int i;
    
    delimiter = get_str(str, min, max);
    
    for(i = 0; i < STR_SIZE; i++)
    {
        if(str[i] == '\0')
        {
            break;
        }
        if(!isdigit(str[i]))
        {
            return DELIMITER_ERROR;
        }
    }
    
    *num = atoi(str);
    
    if(judge_constraint(*num, min, max) == -1)
    {
        return DELIMITER_ERROR;
    }    
    
    return delimiter;
}

DELIMITER_INFO get_str(char *p_str, int min, int max)
{
    unsigned int cnt = 0;
    int ch;
    
    while((ch = getchar()) != -1)
    {
        if(ch == ' ' || ch == '\n')
        {
            p_str[cnt] = '\0';
            if(ch == ' ')
            {
                return BLANK;
            }
            else
            {
                return LINE_FEED;
            }
        }
                        
        p_str[cnt] = ch;
        cnt++;
        
        if(judge_constraint(cnt + 1, min, max) == -1)
        {
            break;
        }
    }
    
    return DELIMITER_ERROR;
}

int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return FAILURE;
    }
    
    return SUCCESS;
}
