#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

int n;
vi c;
vvi edge;
vi ans;

struct stat_info {
    map<int, int> color_count;
    int sum;
    int dominate;
};

stat_info my_empty{map<int, int>(), 0, 0};

stat_info merge(stat_info a, stat_info b) {
    if (a.color_count.size() > b.color_count.size()) {
        return merge(b, a);
    }
    stat_info res = b;
    int old_dominate = res.dominate;
    for (auto x : a.color_count) {
        int color = x.first;
        int count = x.second;
        // remove num from res
        int old_count = res.color_count[color];
        res.color_count.erase(color);
        if (old_count == old_dominate) {
            res.sum -= color;
        }
        // add num back to res
        int new_count = old_count + count;
        res.color_count[color] = new_count;
        if (new_count > res.dominate) {
            res.dominate = new_count;
            res.sum = color;
        } else if (new_count == res.dominate) {
            res.sum += color;
        }
    }
    return res;
}

void inc(stat_info &stat, int color) {
    int count = stat.color_count[color];
    if (count == stat.dominate) {
        stat.sum -= color;
    }
    count++;
    stat.color_count[color] = count;
    if (count > stat.dominate) {
        stat.sum = color;
        stat.dominate = count;
    } else if (count == stat.dominate) {
        stat.sum += color;
    }
}

stat_info dfs(int parent, int root) {
    stat_info res = my_empty;
    for (auto child : edge[root]) {
        if (parent == child) {
            continue;
        }
        auto res_child = dfs(root, child);
        res = merge(res, res_child);
    }
    inc(res, c[root]);
    ans[root] = res.sum;
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    c = vi(n);
    rep(i, 0, n) {
        cin >> c[i];
    }
    edge = vvi(n);
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    // 对每个子树，计算颜色总和，在跟节点处要合并这些子树的颜色。

    ans = vi(n);
    dfs(0, 0);
    rep(i, 0, n) {
        cout << ans[i] << ' ';
    }
}


#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

int n;
vi c;
vvi edge;
vector<ll> ans;

struct stat_info {
    map<int, int> color_count;
    ll sum;
    int dominate;
};

stat_info my_empty{map<int, int>(), 0, 0};

stat_info &merge(stat_info &a, stat_info &b) {
    if (a.color_count.size() > b.color_count.size()) {
        return merge(b, a);
    }
    // debug("a: sum=%d,dominate=%d-----------\n", a.sum, a.dominate);
    // for (auto x : a.color_count) {
    //     debug("%d->%d\n", x.first, x.second);
    // }
    // debug("\n");
    // debug("b: sum=%d,dominate=%d-----------\n", b.sum, b.dominate);
    // for (auto x : b.color_count) {
    //     debug("%d->%d\n", x.first, x.second);
    // }
    // debug("\n");
    // debug("res: sum=%d,dominate=%d-----------\n", res.sum, res.dominate);
    // for (auto x : res.color_count) {
    //     debug("%d->%d\n", x.first, x.second);
    // }
    // debug("\n");
    // first remove num from res
    vii to_change;
    for (auto x : a.color_count) {
        int color = x.first;
        int count = x.second;
        int old_count = b.color_count[color];
        b.color_count.erase(color);
        if (old_count > 0 && old_count == b.dominate) {
            b.sum -= color;
        }
        to_change.push_back({color, old_count + count});
    }
    debug("to_change.size()=%d,b.size()=%d\n",to_change.size(),b.color_count.size());
    for (auto x : to_change) {
        check(b.color_count.find(x.first) == b.color_count.end());
        b.color_count[x.first] = x.second;
        if (x.second > b.dominate) {
            b.sum = x.first;
            b.dominate = x.second;
        } else if (x.second == b.dominate) {
            b.sum += x.first;
        }
    }
    check(b.dominate >= 0 && b.sum >= 0);
    return b;
}

void inc(stat_info &stat, int color) {
    debug("inc, color=%d\n", color);
    int count = stat.color_count[color];
    debug("before count=%d\n", count);
    if (stat.dominate > 0 && count == stat.dominate) {
        debug("stat.sum-=%d\n", color);
        stat.sum -= color;
        check(stat.sum >= 0);
    }
    count++;
    debug("after count=%d\n", count);
    stat.color_count[color] = count;
    if (count > stat.dominate) {
        stat.sum = color;
        stat.dominate = count;
        debug("new dominate and sum: %d, %d\n", stat.dominate, stat.sum);
    } else if (count == stat.dominate) {
        stat.sum += color;
        debug("inc sum by %d to %d\n", color, stat.sum);
    }
    check(stat.dominate >= 0 && stat.sum >= 0);
}

stat_info &dfs(int parent, int root) {
    debug("dfs(%d,%d)\n", parent, root);
    stat_info *new_empty = new stat_info();
    stat_info &res = *new_empty;
    for (auto child : edge[root]) {
        if (parent == child) {
            continue;
        }
        auto res_child = dfs(root, child);
        // debug("before merge\n");
        res = merge(res, res_child);
        // debug("after merge\n");
    }
    inc(res, c[root]);
    ans[root] = res.sum;
    return res;
}

void test() {
    {
        stat_info a = my_empty;
        inc(a, 3);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
    }

    {
        debug("----------------\n");
        stat_info a = my_empty;
        a.color_count[3]++;
        a.dominate = 1;
        a.sum = 3;
        inc(a, 3);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        inc(a, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        inc(a, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
    }

    {
        debug("-------merge---------\n");
        stat_info a = my_empty;
        inc(a, 3);
        inc(a, 4);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        stat_info b = my_empty;
        inc(b, 3);
        inc(b, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", b.sum, b.dominate, b.color_count.size());
        stat_info c = merge(a, b);
        debug("sum=%d,dominate=%d,map.size=%d\n", c.sum, c.dominate, c.color_count.size());
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    test();

    cin >> n;
    c = vi(n);
    rep(i, 0, n) {
        cin >> c[i];
    }
    edge = vvi(n);
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    // 对每个子树，计算颜色总和，在跟节点处要合并这些子树的颜色。

    ans = vector<ll>(n);
    dfs(0, 0);
    rep(i, 0, n) {
        cout << ans[i] << ' ';
    }
    debug("my_empty: %d, %d\n", my_empty.sum, my_empty.dominate);
}


#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

int n;
vi c;
vvi edge;
vi ans;

struct stat_info {
    map<int, int> color_count;
    int sum;
    int dominate;
};

stat_info my_empty{map<int, int>(), 0, 0};

stat_info merge(stat_info a, stat_info b) {
    if (a.color_count.size() > b.color_count.size()) {
        return merge(b, a);
    }
    stat_info res = b;
    int old_dominate = res.dominate;
    debug("a: sum=%d,dominate=%d-----------\n", a.sum, a.dominate);
    for (auto x : a.color_count) {
        debug("%d->%d\n", x.first, x.second);
    }
    debug("\n");
    debug("b: sum=%d,dominate=%d-----------\n", b.sum, b.dominate);
    for (auto x : b.color_count) {
        debug("%d->%d\n", x.first, x.second);
    }
    debug("\n");
    debug("res: sum=%d,dominate=%d-----------\n", res.sum, res.dominate);
    for (auto x : res.color_count) {
        debug("%d->%d\n", x.first, x.second);
    }
    debug("\n");
    // first remove num from res
    vii to_change;
    for (auto x : a.color_count) {
        int color = x.first;
        int count = x.second;
        int old_count = res.color_count[color];
        res.color_count.erase(color);
        if (old_count > 0 && old_count == res.dominate) {
            res.sum -= color;
        }
        to_change.push_back({color, old_count + count});
    }
    for (auto x : to_change) {
        check(res.color_count.find(x.first) == res.color_count.end());
        res.color_count[x.first] = x.second;
        if (x.second > res.dominate) {
            res.sum = x.first;
            res.dominate = x.second;
        } else if (x.second == res.dominate) {
            res.sum += x.first;
        }
    }
    // for (auto x : a.color_count) {
    //     int color = x.first;
    //     int count = x.second;
    //     // remove num from res
    //     int old_count = res.color_count[color];
    //     res.color_count.erase(color);
    //     if (old_dominate > 0 && old_count == old_dominate) {
    //         debug("sum=%d,dominate=%d,color=%d,old_count=%d\n", res.sum, old_dominate, color, old_count);
    //         res.sum -= color;
    //         check(res.sum >= 0);
    //     }
    //     // add num back to res
    //     int new_count = old_count + count;
    //     res.color_count[color] = new_count;
    //     if (new_count > res.dominate) {
    //         res.dominate = new_count;
    //         res.sum = color;
    //     } else if (new_count == res.dominate) {
    //         res.sum += color;
    //     }
    // }
    check(res.dominate >= 0 && res.sum >= 0);
    return res;
}

void inc(stat_info &stat, int color) {
    debug("inc, color=%d\n", color);
    int count = stat.color_count[color];
    debug("before count=%d\n", count);
    if (stat.dominate > 0 && count == stat.dominate) {
        debug("stat.sum-=%d\n", color);
        stat.sum -= color;
        check(stat.sum >= 0);
    }
    count++;
    debug("after count=%d\n", count);
    stat.color_count[color] = count;
    if (count > stat.dominate) {
        stat.sum = color;
        stat.dominate = count;
        debug("new dominate and sum: %d, %d\n", stat.dominate, stat.sum);
    } else if (count == stat.dominate) {
        stat.sum += color;
        debug("inc sum by %d to %d\n", color, stat.sum);
    }
    check(stat.dominate >= 0 && stat.sum >= 0);
}

stat_info dfs(int parent, int root) {
    stat_info res = my_empty;
    for (auto child : edge[root]) {
        if (parent == child) {
            continue;
        }
        auto res_child = dfs(root, child);
        res = merge(res, res_child);
    }
    inc(res, c[root]);
    ans[root] = res.sum;
    return res;
}

void test() {
    {
        stat_info a = my_empty;
        inc(a, 3);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
    }

    {
        debug("----------------\n");
        stat_info a = my_empty;
        a.color_count[3]++;
        a.dominate = 1;
        a.sum = 3;
        inc(a, 3);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        inc(a, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        inc(a, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
    }

    {
        debug("-------merge---------\n");
        stat_info a = my_empty;
        inc(a, 3);
        inc(a, 4);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        stat_info b = my_empty;
        inc(b, 3);
        inc(b, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", b.sum, b.dominate, b.color_count.size());
        stat_info c = merge(a, b);
        debug("sum=%d,dominate=%d,map.size=%d\n", c.sum, c.dominate, c.color_count.size());
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    test();

    cin >> n;
    c = vi(n);
    rep(i, 0, n) {
        cin >> c[i];
    }
    edge = vvi(n);
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    // 对每个子树，计算颜色总和，在跟节点处要合并这些子树的颜色。

    ans = vi(n);
    dfs(0, 0);
    rep(i, 0, n) {
        cout << ans[i] << ' ';
    }
}


#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

int n;
vi c;
vvi edge;
vi ans;

struct stat_info {
    map<int, int> color_count;
    ll sum;
    int dominate;
};

stat_info my_empty{map<int, int>(), 0, 0};

stat_info &merge(stat_info &a, stat_info &b) {
    if (a.color_count.size() > b.color_count.size()) {
        return merge(b, a);
    }
    // debug("a: sum=%d,dominate=%d-----------\n", a.sum, a.dominate);
    // for (auto x : a.color_count) {
    //     debug("%d->%d\n", x.first, x.second);
    // }
    // debug("\n");
    // debug("b: sum=%d,dominate=%d-----------\n", b.sum, b.dominate);
    // for (auto x : b.color_count) {
    //     debug("%d->%d\n", x.first, x.second);
    // }
    // debug("\n");
    // debug("res: sum=%d,dominate=%d-----------\n", res.sum, res.dominate);
    // for (auto x : res.color_count) {
    //     debug("%d->%d\n", x.first, x.second);
    // }
    // debug("\n");
    // first remove num from res
    vii to_change;
    for (auto x : a.color_count) {
        int color = x.first;
        int count = x.second;
        int old_count = b.color_count[color];
        b.color_count.erase(color);
        if (old_count > 0 && old_count == b.dominate) {
            b.sum -= color;
        }
        to_change.push_back({color, old_count + count});
    }
    debug("to_change.size()=%d,b.size()=%d\n",to_change.size(),b.color_count.size());
    for (auto x : to_change) {
        check(b.color_count.find(x.first) == b.color_count.end());
        b.color_count[x.first] = x.second;
        if (x.second > b.dominate) {
            b.sum = x.first;
            b.dominate = x.second;
        } else if (x.second == b.dominate) {
            b.sum += x.first;
        }
    }
    check(b.dominate >= 0 && b.sum >= 0);
    return b;
}

void inc(stat_info &stat, int color) {
    debug("inc, color=%d\n", color);
    int count = stat.color_count[color];
    debug("before count=%d\n", count);
    if (stat.dominate > 0 && count == stat.dominate) {
        debug("stat.sum-=%d\n", color);
        stat.sum -= color;
        check(stat.sum >= 0);
    }
    count++;
    debug("after count=%d\n", count);
    stat.color_count[color] = count;
    if (count > stat.dominate) {
        stat.sum = color;
        stat.dominate = count;
        debug("new dominate and sum: %d, %d\n", stat.dominate, stat.sum);
    } else if (count == stat.dominate) {
        stat.sum += color;
        debug("inc sum by %d to %d\n", color, stat.sum);
    }
    check(stat.dominate >= 0 && stat.sum >= 0);
}

stat_info &dfs(int parent, int root) {
    debug("dfs(%d,%d)\n", parent, root);
    stat_info *new_empty = new stat_info();
    stat_info &res = *new_empty;
    for (auto child : edge[root]) {
        if (parent == child) {
            continue;
        }
        auto res_child = dfs(root, child);
        // debug("before merge\n");
        res = merge(res, res_child);
        // debug("after merge\n");
    }
    inc(res, c[root]);
    ans[root] = res.sum;
    return res;
}

void test() {
    {
        stat_info a = my_empty;
        inc(a, 3);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
    }

    {
        debug("----------------\n");
        stat_info a = my_empty;
        a.color_count[3]++;
        a.dominate = 1;
        a.sum = 3;
        inc(a, 3);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        inc(a, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        inc(a, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
    }

    {
        debug("-------merge---------\n");
        stat_info a = my_empty;
        inc(a, 3);
        inc(a, 4);
        debug("sum=%d,dominate=%d,map.size=%d\n", a.sum, a.dominate, a.color_count.size());
        stat_info b = my_empty;
        inc(b, 3);
        inc(b, 2);
        debug("sum=%d,dominate=%d,map.size=%d\n", b.sum, b.dominate, b.color_count.size());
        stat_info c = merge(a, b);
        debug("sum=%d,dominate=%d,map.size=%d\n", c.sum, c.dominate, c.color_count.size());
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    test();

    cin >> n;
    c = vi(n);
    rep(i, 0, n) {
        cin >> c[i];
    }
    edge = vvi(n);
    rep(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    // 对每个子树，计算颜色总和，在跟节点处要合并这些子树的颜色。

    ans = vi(n);
    dfs(0, 0);
    rep(i, 0, n) {
        cout << ans[i] << ' ';
    }
    debug("my_empty: %d, %d\n", my_empty.sum, my_empty.dominate);
}


/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<stdlib.h>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 100005
#define nm 2000005
#define pi 3.1415926535897931
const ll inf=1e9+7;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar() ;
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,v[NM],_t;
priority_queue<int>q[NM];

int main(){
    n=read();
    inc(i,1,n){
	for(int j=1;sqr(j)<=i;j++)if(i%j==0){
	    v[j]++;if(j<i/j)v[i/j]++;
	}
    }
    dec(i,n,1)if(v[i])q[v[i]].push(i);
    _t=1;
    dec(i,n,1){
	while(!q[i].empty()&&q[i].top()%_t)q[i].pop();
	if(q[i].empty())printf("%d ",_t);
	else printf("%d ",_t=q[i].top());
    }
    return 0;
}


/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<stdlib.h>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 1000005
#define nm 2000005
#define pi 3.1415926535897931
const ll inf=1e9+7;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar() ;
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,v[NM],_t,c[NM],tot,cnt;
priority_queue<int>q[NM];

void dfs(int x){
    if(x==tot+1){v[cnt]++;return;}
    cnt*=c[x];dfs(x+1);cnt/=c[x];dfs(x+1);
}

int main(){
    n=read();cnt=1;
    inc(i,1,n){
	int t=i;tot=0;
	for(int j=2;sqr(j)<t;j++)while(t%j==0)t/=j,c[++tot]=j;
	if(t>1)c[++tot]=t;
	dfs(1);
    }
    dec(i,n,1)if(v[i])q[v[i]].push(i);
    _t=1;
    dec(i,n,1){
	while(!q[i].empty()&&q[i].top()%_t)q[i].pop();
	if(q[i].empty())printf("%d ",_t);
	else printf("%d ",_t=q[i].top());
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n==3){
		printf("1 1 3\n");
		return 0;
	}
	int now=1;
	int jug=0;
	while(n){
		if(n%2==1){
			n++;
			jug=1;
		}
		for(int i=1;i<=n/2;i++){
			printf("%d ",now);

		}
		n=(n-jug)/2;
		now=now*2;
		jug=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int now=1;
	int jug=0;
	while(n){
		if(n%2==1){
			n++;
			jug=1;
		}
		for(int i=1;i<=n/2;i++){
			printf("%d ",now);

		}
		n=(n-jug)/2;
		now=now*2;
		jug=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int m=n;
	if(n==3){
		printf("1 1 3\n");
		return 0;
	}
	int now=1;
	while(n>3){
		for(int i=1;i<=(n+1)/2;i++){
			printf("%d ",now);
		}
		n=n/2;
		now=now*2;
	}
	if(n==3){
		printf("%d %d %d ",now,now*2,now*3);
	}else if(n==2){
		printf("%d %d ",now,now*2);
	}else{
		printf("%d",now);
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int m=n;
	if(n==3){
		printf("1 1 3\n");
		return 0;
	}
	int now=1;
	int jug=0;
	while(n){
		if(n%2==1){
			n++;
			jug=1;
		}
		for(int i=1;i<=n/2;i++){
			printf("%d ",now);

		}
		n=(n-jug)/2;
		now=now*2;
		if(n==3){
			printf("%d %d %d ",now,now,m);
			break;
		}
		jug=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int m=n;
	if(n==3){
		printf("1 1 3\n");
		return 0;
	}
	int now=1;
	while(n>3){
		for(int i=1;i<=(n+1)/2;i++){
			printf("%d ",now);
		}
		n=n/2;
		now=now*2;
	}
	if(n==3){
		printf("%d %d %d ",now,now,now*3);
	}else if(n==2){
		printf("%d %d ",now,now*2);
	}else{
		printf("%d",now);
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int m=n;
	if(n==3){
		printf("1 1 3\n");
		return 0;
	}
	int now=1;
	int jug=0;
	while(n){
		if(n%2==1){
			n++;
			jug=1;
		}
		for(int i=1;i<=n/2;i++){
			printf("%d ",now);
		}
		n=(n-jug)/2;
		now=now*2;
		if(n==3&&m%2==0){
			printf("%d %d %d ",now,now,m);
			break;
		}
		if(n==3&&m%2==1){
			printf("%d %d %d ",now,now,m-1);
			break;
		}
		jug=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n==3){
		printf("1 1 3\n");
	}
	int now=1;
	int jug=0;
	while(n){
		if(n%2==1){
			n++;
			jug=1;
		}
		for(int i=1;i<=n/2;i++){
			printf("%d ",now);

		}
		n=(n-jug)/2;
		now=now*2;
		jug=0;
	}
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(i=j;i<=k;i++)
#define FORK(i,j,k) for(i=j;i<k;i++)
#define FORN(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ll long long

typedef pair<int,int> ii;

template <typename T> inline void read(T &x) {
	char c; bool nega=false;
	while ((!isdigit(c=getchar())) && (c!='-'));
	if (c=='-') {
		nega=true; c=getchar();
	}
	x=c-48;
	while (isdigit(c=getchar())) x=x*10+c-48;
	if (nega) x=-x;
}

template <typename T> inline void writep(T x) {
	if (x>9) writep(x/10);
	putchar(x%10+48);
}

template <typename T> inline void write(T x) {
	if (x<0) {
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x) {
	write(x);
	putchar('\n');
}

//___________________________________________________

vector<int> us;

int main () {
    int n; read(n);
    int u=-1, i;
    FOR(i, 2, n) {
        if ((n%i)==0) {
            if (u==-1) {
                u=i; us.pb(i);
            }
            else {
                if ((i%u)==0) us.pb(i);
            }
        }
    }
    int rm=n, pre=1;
    int j, tmp;
    FORK(i, 0, us.size()) {
        tmp=n/us[i];
        FOR(j, 1, rm-tmp) {
            write(pre); putchar(' ');
        }
        rm=tmp; pre=us[i];
    }
    writeln(n);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(i=j;i<=k;i++)
#define FORK(i,j,k) for(i=j;i<k;i++)
#define FORN(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ll long long

typedef pair<int,int> ii;

template <typename T> inline void read(T &x) {
	char c; bool nega=false;
	while ((!isdigit(c=getchar())) && (c!='-'));
	if (c=='-') {
		nega=true; c=getchar();
	}
	x=c-48;
	while (isdigit(c=getchar())) x=x*10+c-48;
	if (nega) x=-x;
}

template <typename T> inline void writep(T x) {
	if (x>9) writep(x/10);
	putchar(x%10+48);
}

template <typename T> inline void write(T x) {
	if (x<0) {
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x) {
	write(x);
	putchar('\n');
}

//___________________________________________________

vector<int> us;

int main () {
    int n; read(n);
    int u=-1, i, pre=1;
    FOR(i, 2, n) {
        if ((n%i)==0) {
            if (u==-1) {
                u=i; us.pb(i);
                pre=i;
            }
            else {
                if ((i%pre)==0) {
                    us.pb(i); pre=i;
                }
            }
        }
    }
    int rm=n; pre=1;
    int j, tmp;
    FORK(i, 0, us.size()) {
        tmp=n/us[i];
        FOR(j, 1, rm-tmp) {
            write(pre); putchar(' ');
        }
        rm=tmp; pre=us[i];
    }
    writeln(n);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(i=j;i<=k;i++)
#define FORK(i,j,k) for(i=j;i<k;i++)
#define FORN(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ll long long

typedef pair<int,int> ii;

template <typename T> inline void read(T &x) {
	char c; bool nega=false;
	while ((!isdigit(c=getchar())) && (c!='-'));
	if (c=='-') {
		nega=true; c=getchar();
	}
	x=c-48;
	while (isdigit(c=getchar())) x=x*10+c-48;
	if (nega) x=-x;
}

template <typename T> inline void writep(T x) {
	if (x>9) writep(x/10);
	putchar(x%10+48);
}

template <typename T> inline void write(T x) {
	if (x<0) {
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x) {
	write(x);
	putchar('\n');
}

//___________________________________________________

vector<int> us;

int main () {
    int n; read(n);
    int i;
    if (n<=3) {
        FORK(i, 1, n) {
            write(1); putchar(' ');
        }
        writeln(n); return 0;
    }
    int tmp=1, dm;
    while (n!=0) {
        if (n%2) {
            write(tmp); putchar(' ');
            n--;
        }
        FOR(i, 1, n/2) {
            write(tmp); putchar(' ');
        }
        n/=2; tmp*=2;
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(i=j;i<=k;i++)
#define FORK(i,j,k) for(i=j;i<k;i++)
#define FORN(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ll long long

typedef pair<int,int> ii;

template <typename T> inline void read(T &x) {
	char c; bool nega=false;
	while ((!isdigit(c=getchar())) && (c!='-'));
	if (c=='-') {
		nega=true; c=getchar();
	}
	x=c-48;
	while (isdigit(c=getchar())) x=x*10+c-48;
	if (nega) x=-x;
}

template <typename T> inline void writep(T x) {
	if (x>9) writep(x/10);
	putchar(x%10+48);
}

template <typename T> inline void write(T x) {
	if (x<0) {
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x) {
	write(x);
	putchar('\n');
}

//___________________________________________________

vector<int> us;

int main () {
    int n; read(n);
    int u=-1, i, pre=1;
    if ((n>3) && (n%2)) {
        write(1); putchar(' ');
        n--;
    }
    FOR(i, 2, n) {
        if ((n%i)==0) {
            if (u==-1) {
                u=i; us.pb(i);
                pre=i;
            }
            else {
                if ((i%pre)==0) {
                    us.pb(i); pre=i;
                }
            }
        }
    }
    int rm=n; pre=1;
    int j, tmp;
    FORK(i, 0, us.size()) {
        tmp=n/us[i];
        FOR(j, 1, rm-tmp) {
            write(pre); putchar(' ');
        }
        rm=tmp; pre=us[i];
    }
    writeln(n);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(i=j;i<=k;i++)
#define FORK(i,j,k) for(i=j;i<k;i++)
#define FORN(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ll long long

typedef pair<int,int> ii;

template <typename T> inline void read(T &x) {
	char c; bool nega=false;
	while ((!isdigit(c=getchar())) && (c!='-'));
	if (c=='-') {
		nega=true; c=getchar();
	}
	x=c-48;
	while (isdigit(c=getchar())) x=x*10+c-48;
	if (nega) x=-x;
}

template <typename T> inline void writep(T x) {
	if (x>9) writep(x/10);
	putchar(x%10+48);
}

template <typename T> inline void write(T x) {
	if (x<0) {
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x) {
	write(x);
	putchar('\n');
}

//___________________________________________________

int main () {
    int n; read(n);
    int i;
    int tmp=1, dm;
    while (n>3) {
        if (n%2) {
            write(tmp); putchar(' ');
            n--;
        }
        FOR(i, 1, n/2) {
            write(tmp); putchar(' ');
        }
        n/=2; tmp*=2;
    }
    if (n<=3) {
        FORK(i, 1, n) {
            write(tmp); putchar(' ');
        }
        writeln(tmp*n); return 0;
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,j,k) for(i=j;i<=k;i++)
#define FORK(i,j,k) for(i=j;i<k;i++)
#define FORN(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ll long long

typedef pair<int,int> ii;

template <typename T> inline void read(T &x) {
	char c; bool nega=false;
	while ((!isdigit(c=getchar())) && (c!='-'));
	if (c=='-') {
		nega=true; c=getchar();
	}
	x=c-48;
	while (isdigit(c=getchar())) x=x*10+c-48;
	if (nega) x=-x;
}

template <typename T> inline void writep(T x) {
	if (x>9) writep(x/10);
	putchar(x%10+48);
}

template <typename T> inline void write(T x) {
	if (x<0) {
		putchar('-');
		x=-x;
	}
	writep(x);
}

template <typename T> inline void writeln(T x) {
	write(x);
	putchar('\n');
}

//___________________________________________________

vector<int> us;

int main () {
    int n; read(n);
    int tmp=1, dm;
    int i;
    while (n!=0) {
        if (n%2) {
            write(tmp); putchar(' ');
            n--;
        }
        FOR(i, 1, n/2) {
            write(tmp); putchar(' ');
        }
        n/=2; tmp*=2;
    }
	return 0;
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin>>n;
	bool flag=false;
	int y=1;
	if(n!=3 && n%2==1)
	{
		cout<<"1 ";
		n--;
	}
	while(!flag)
	{
		if(y>=n)
			flag=true;
		int r = n/y;
		int s = n/(2*y);
		int tempe = r-s;

		for(int i=1;i<=tempe && y<=n;i++)
			cout<<y<<" ";
		if(n%y==0 && y*2>n/2)
			y=n;
		else
			y=y*2;
	}
    return 0;
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin>>n;

	int x=1,i,p = log2(n);
	if(n==1)
		cout<<"1";
	else if(n==3)
	{
		cout<<"1 1 3";
	}
	else
	{
		for(i=1;i<=n-p;i++)
			cout<<"1 ";
		for(i=p+1;i<=n;i++)
		{
			x*=2;
			cout<<x<<" ";
		}
	}
    return 0;
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MAX 1000000
bool* v = NULL;
int* sp = NULL;
void Sieve();

int main()
{
	int n,Gcd;
	cin>>n;
	int* ans = NULL;
    ans = new int[n+1];
    v = new bool[MAX];
    sp = new int[MAX];
    for(int i=1;i<=n;i++)
	{
		if(i==1)
			Gcd = i;
		else
			Gcd = __gcd(Gcd,i);
	}
	Sieve();
	int temp=n;
	for(int i=0;i<n;i++)
	{
		ans[n-i]=temp;
		temp = temp/sp[temp];
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
    return 0;
}

void Sieve(){
	sp[0]=0;
	sp[1]=1;
	for (int i = 2; i < MAX; i += 2)	{sp[i] = 2;}//even numbers have smallest prime factor 2
	for (ll i = 3; i < MAX; i += 2)
	{
		if (!v[i]){
			sp[i] = i;
			for (ll j = i; (j*i) < MAX; j += 2){
				if (!v[j*i])	v[j*i] = true, sp[j*i] = i;
			}
		}
	}
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int n,y=1;
	cin>>n;
	int r = n/y , s = n/(2*y) , p=log2(n);
	bool flag1=true,flag2=false;

	while(flag1)
	{
		if(y>=n || flag2)
			flag1 = false;
		for(int i=1;i<=r-s && y<=n;i++)
			cout<<y<<" ";
		if( 4*y>n && n!=pow(2,p) && n>=pow(2,p)+pow(2,p-1))
		{
			y=pow(2,p)+pow(2,p-1);
			r=s+1;
			flag2=true;
		}
		else
		{
			y*=2;
			r = n/y;
			s = n/(2*y);
		}
	}
    return 0;
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin>>n;

	int x=1,i,p = log2(n);
	if(n==1)
		cout<<"1";
	else if(n==3)
	{
		cout<<"1 1 3";
	}
	else
	{
		for(i=1;i<=n-p;i++)
			cout<<"1 ";
		for(i=n-p+1;i<=n;i++)
		{
			x*=2;
			cout<<x<<" ";
		}
	}
    return 0;
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin>>n;

	int x=1,i,p = log2(n);
	if(n==3)
		cout<<"1 1 3";
	else
	{
		for(i=1;i<=n-p;i++)
			cout<<"1 ";
		for(i=p+1;i<=n;i++)
		{
			x*=2;
			cout<<x<<" ";
		}
	}
    return 0;
}


/*
  Author: GracefuISage
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MAX 1000000
bool* v = NULL;
int* sp = NULL;
void Sieve();

int main()
{
	int n,Gcd,maxi=0;
	cin>>n;
    int* arr = NULL;
    arr = new int[n+1];
    v = new bool[MAX];
    sp = new int[MAX];
    for(int i=1;i<=n;i++)
	{
		arr[i] = i;
		if(i==1)
			Gcd = arr[i];
		else
			Gcd = __gcd(Gcd,arr[i]);
	}
	Sieve();
	for(int i=n;i>=1;i--)
	{
		if(sp[i]==i)
		{maxi=i;break;}
	}
	for(int i=1;i<n;i++)
		cout<<"1"<<" ";
	cout<<maxi;
    return 0;
}

void Sieve(){
	sp[0]=0;
	sp[1]=1;
	for (int i = 2; i < MAX; i += 2)	{sp[i] = 2;}//even numbers have smallest prime factor 2
	for (ll i = 3; i < MAX; i += 2)
	{
		if (!v[i]){
			sp[i] = i;
			for (ll j = i; (j*i) < MAX; j += 2){
				if (!v[j*i])	v[j*i] = true, sp[j*i] = i;
			}
		}
	}
}


// Problem : C. Sequence Transformation
// Contest : Codeforces Round #514 (Div. 2)
// URL : https://codeforces.com/problemset/problem/1059/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n==1)
{
cout<<1;return 0;}
else if(n==3)
{
	cout<<1<<" "<<1<<" "<<3;
	return 0;}
vi a(n+1);
vi v;
for(int i=2;i<=n;i*=2)
v.pb(i);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i]++;
for(int i=n;i>=1;i--)
for(auto it=upper_bound(v.begin(),v.end(),i);it!=v.end();it++)
a[i]-=a[*it];
for(int i=1;i<=n;i*=2)
{
if(i*2>n && a[i]==1)
cout<<n/(i/2)*(i/2);
else
	while(a[i]--)
	cout<<i<<" ";
}
}


// Problem : C. Sequence Transformation
// Contest : Codeforces Round #514 (Div. 2)
// URL : https://codeforces.com/problemset/problem/1059/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n==3)
{
	cout<<1<<" "<<1<<" "<<3;
	return 0;
}
else if(n==7)
{
	cout<<1<<" "<<1<<" "<<1<<" "<<1<<" "<<2<<" "<<2<<" "<<6;
	return 0;
}
else if(n==6)
{
	cout<<1<<" "<<1<<" "<<1<<" "<<2<<" "<<2<<" "<<6;
	return 0;
}
vi a(n+1);
vi v;
for(int i=2;i<=n;i*=2)
v.pb(i);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i]++;
for(int i=n;i>=1;i--)
for(auto it=upper_bound(v.begin(),v.end(),i);it!=v.end();it++)
a[i]-=a[*it];
for(int i=1;i<=n;i*=2)
{
	while(a[i]--)
	cout<<i<<" ";
}
}


// Problem : C. Sequence Transformation
// Contest : Codeforces Round #514 (Div. 2)
// URL : https://codeforces.com/problemset/problem/1059/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n==1)
{
cout<<1;return 0;}
else if(n==3)
{
	cout<<1<<" "<<1<<" "<<3;
	return 0;}
vi a(n+1);
vi v;
for(int i=2;i<=n;i*=2)
v.pb(i);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i]++;
for(int i=n;i>=1;i--)
for(auto it=upper_bound(v.begin(),v.end(),i);it!=v.end();it++)
a[i]-=a[*it];
for(int i=1;i<=n;i*=2)
{
if(i*2>n && a[i]==1)
cout<<n/2*2;
else
	while(a[i]--)
	cout<<i<<" ";
}
}


// Problem : C. Sequence Transformation
// Contest : Codeforces Round #514 (Div. 2)
// URL : https://codeforces.com/problemset/problem/1059/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n==3)
{
	cout<<1<<" "<<1<<" "<<3;
	return 0;
}
else if(n==7)
{
	cout<<1<<" "<<1<<" "<<1<<" "<<1<<" "<<2<<" "<<2<<" "<<6;
	return 0;
}
vi a(n+1);
vi v;
for(int i=2;i<=n;i*=2)
v.pb(i);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i]++;
for(int i=n;i>=1;i--)
for(auto it=upper_bound(v.begin(),v.end(),i);it!=v.end();it++)
a[i]-=a[*it];
for(int i=1;i<=n;i*=2)
{
	while(a[i]--)
	cout<<i<<" ";
}
}


// Problem : C. Sequence Transformation
// Contest : Codeforces Round #514 (Div. 2)
// URL : https://codeforces.com/problemset/problem/1059/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n==3)
{
	cout<<1<<" "<<1<<" "<<3;
	return 0;
}
else if(n==7)
{
	cout<<1<<" "<<1<<" "<<1<<" "<<1<<" "<<2<<" "<<2<<" "<<6;
	return 0;
}
else if(n==6)
{
	cout<<1<<" "<<1<<" "<<1<<" "<<1<<" "<<2<<" "<<2<<" "<<6;
	return 0;
}
vi a(n+1);
vi v;
for(int i=2;i<=n;i*=2)
v.pb(i);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i]++;
for(int i=n;i>=1;i--)
for(auto it=upper_bound(v.begin(),v.end(),i);it!=v.end();it++)
a[i]-=a[*it];
for(int i=1;i<=n;i*=2)
{
	while(a[i]--)
	cout<<i<<" ";
}
}


// Problem : C. Sequence Transformation
// Contest : Codeforces Round #514 (Div. 2)
// URL : https://codeforces.com/problemset/problem/1059/C
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int n;
cin>>n;
if(n==1)
{
cout<<1;return 0;}
else if(n==3)
{
	cout<<1<<" "<<3;
	return 0;}
vi a(n+1);
vi v;
for(int i=2;i<=n;i*=2)
v.pb(i);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i]++;
for(int i=n;i>=1;i--)
for(auto it=upper_bound(v.begin(),v.end(),i);it!=v.end();it++)
a[i]-=a[*it];
for(int i=1;i<=n;i*=2)
{
if(i*2>n && a[i]==1)
cout<<n/2*2;
else
	while(a[i]--)
	cout<<i<<" ";
}
}


#include <bits/stdc++.h>

using namespace std;

bool mark[1000010] = {0};

int main() {
    int n;
    cin >> n;
    if(n <= 3) {
        cout << "1 1 3" << endl;
        return 0;
    }
    int val = 1;
    while(n > 0) {
        int part = n - n/2;
        for(int i = 0; i < part; ++i) {
            printf("%d\n", val);
        }
        val *= 2;
        n -= part;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

std::vector<int> res;

int main() {
    int n;
    cin >> n;
    vector<int> A, B;
    for(int i = 1; i <= n; ++i) {
        A.push_back(i);
    }
    int val = 1;
    while(A.empty() == false) {
        if(A.size() == 3) {
            res.push_back(A[0]*val);
            res.push_back(A[1]*val);
            res.push_back(A[2]*val);
            break;
        }
        for(size_t i = 0; i < A.size(); ++i) {
            if(A[i]&1) {
                res.push_back(A[0]*val);
            } else {
                B.push_back(A[i]/2);
            }
        }
        val <<= 1;
        //cout << B.size() << "\t" << B[0] << endl;
        A.resize(0);
        swap(A, B);
    }
    for(size_t i = 0; i < res.size(); ++i) {
        printf("%d\n", res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

std::vector<int> res;

int main() {
    int n;
    cin >> n;
    vector<int> A, B;
    for(int i = 1; i <= n; ++i) {
        A.push_back(i);
    }
    int val = 1;
    while(A.empty() == false) {
        if(A.size() == 3) {
            res.push_back(A[0]*val);
            res.push_back(A[0]*val);
            res.push_back(A[2]*val);
            break;
        }
        for(size_t i = 0; i < A.size(); ++i) {
            if(A[i]&1) {
                res.push_back(A[0]*val);
            } else {
                B.push_back(A[i]/2);
            }
        }
        val <<= 1;
        //cout << B.size() << "\t" << B[0] << endl;
        A.resize(0);
        swap(A, B);
    }
    for(size_t i = 0; i < res.size(); ++i) {
        printf("%d\n", res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool mark[1000010] = {0};

int main() {
    int n;
    cin >> n;
    int val = 1;
    while(n > 0) {
        int part = n - n/2;
        for(int i = 0; i < part; ++i) {
            printf("%d\n", val);
        }
        val *= 2;
        n -= part;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool mark[1000010] = {0};

int main() {
    int n;
    cin >> n;
    for(int i = 2; i <= n; ++i) {
        if(mark[i]) { continue; }
        for(int j = i+i; j <= n; j += i) {
            mark[j] = true;
        }
    }
    int m = 0;
    for(int i = n; i >= 1; --i) {
        if(mark[i] == false) {
            m = i;
            break;
        }
    }
    for(int i = 1; i < n; ++i) {
        printf("1 ");
    }
    printf("%d\n", m);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool mark[1000010] = {0};

int main() {
    int n;
    cin >> n;
    if(n == 3) {
        cout << "1 1 3" << endl;
        return 0;
    }
    int val = 1;
    while(n > 0) {
        int part = n - n/2;
        for(int i = 0; i < part; ++i) {
            printf("%d\n", val);
        }
        val *= 2;
        n -= part;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fn(i,n) for(int i=0 ; i< int(n) ; i++)
#define cf(i,c,n) for(int i=int(c) ; i< int(n) ; i++)
#define df(i,n) for(int i=int(n) ; i>=0 ; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long ul;
const int INF=1e9;
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,nn;
    cin>>n;
    nn=n/2*2;
    if(n==3)return cout<<"1 1 3",0;
    for(i=1;n!=1 && n!=3;i*=2,n/=2){
        int nw=(n+1)/2;
        while(nw--)cout<<i<<" ";
    }
    if(n==1)cout<<i;
    if(n==3){
        cout<<i<<" "<<i<<" ";
        int last=0;
        while(last<nn)last+=i;
        cout<<last;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fn(i,n) for(int i=0 ; i< int(n) ; i++)
#define cf(i,c,n) for(int i=int(c) ; i< int(n) ; i++)
#define df(i,n) for(int i=int(n) ; i>=0 ; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long ul;
const int INF=1e9;
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,nn;
    cin>>n;
    nn=n/2*2;
    if(n==3)return cout<<"1 1 3",0;
    for(i=1;n!=1 && n!=3;i*=2,n/=2){
        int nw=(n+1)/2;
        while(nw--)cout<<i<<" ";
    }
    if(n==1)cout<<i;
    if(n==3){
        cout<<i<<" "<<i<<" ";
        int last=0;
        while(last+i<=nn)last+=i;
        cout<<last;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fn(i,n) for(int i=0 ; i< int(n) ; i++)
#define cf(i,c,n) for(int i=int(c) ; i< int(n) ; i++)
#define df(i,n) for(int i=int(n) ; i>=0 ; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long ul;
const int INF=1e9;
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i;
    cin>>n;
    for(i=1;n!=1;i*=2,n/=2){
        int nw=(n+1)/2;
        while(nw--)cout<<i<<" ";
    }
    cout<<i;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fn(i,n) for(int i=0 ; i< int(n) ; i++)
#define cf(i,c,n) for(int i=int(c) ; i< int(n) ; i++)
#define df(i,n) for(int i=int(n) ; i>=0 ; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long ul;
const int INF=1e9;
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i;
    cin>>n;
    if(n==3)return cout<<"1 1 3",0;
    for(i=1;n!=1;i*=2,n/=2){
        int nw=(n+1)/2;
        while(nw--)cout<<i<<" ";
    }
    cout<<i;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fn(i,n) for(int i=0 ; i< int(n) ; i++)
#define cf(i,c,n) for(int i=int(c) ; i< int(n) ; i++)
#define df(i,n) for(int i=int(n) ; i>=0 ; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long ul;
const int INF=1e9;
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,nn;
    cin>>n;
    nn=n/2*2;
    for(i=1;n!=1 && n!=3;i*=2,n/=2){
        int nw=(n+1)/2;
        while(nw--)cout<<i<<" ";
    }
    if(n==1)cout<<i;
    if(n==3){
        cout<<i<<" "<<i<<" ";
        int last=0;
        while(last<nn)last+=i;
        cout<<last;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fn(i,n) for(int i=0 ; i< int(n) ; i++)
#define cf(i,c,n) for(int i=int(c) ; i< int(n) ; i++)
#define df(i,n) for(int i=int(n) ; i>=0 ; i--)
typedef long long ll;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long ul;
const int INF=1e9;
#define F first
#define S second

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,nn;
    cin>>n;
    nn=n;
    for(i=1;n!=1 && n!=3;i*=2,n/=2){
        int nw=(n+1)/2;
        while(nw--)cout<<i<<" ";
    }
    if(n==1)cout<<i;
    if(n==3){
        cout<<i<<" "<<i<<" ";
        int last=0;
        while(last<nn)last+=i;
        cout<<last;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)
        return cout<<1<<endl,0;
    if(n==2)
        return cout<<1<<' '<<2<<endl,0;
    if(n==3)
        return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    for(i=2; i<=n; i++)
        st.insert(i);

    res=1;

    last=1;

    kilk=n-1;

    for(i=3; i<=n; i+=2)
        cout<<1<<' ',kilk--,st.erase(i);

    if(kilk==3)
    {
        long long gcd=*(st.begin());
        for(auto to:st)
        {
            gcd=__gcd(to,gcd);
        }
        cout<<gcd<<' ';
        st.erase(st.begin());
        cout<<__gcd(*(st.begin()),*(st.rbegin()))<<' ';
        cout<<*(st.rbegin())<<endl;
        return 0;
    }

    while(res<=n)
    {
        res*=2;
        last=2;
        for(i=2; i<=n; i+=2)
        {
            if(i%res==0 && i%(res*2)!=0)
            {
                cout<<last<<' ';
                kilk--;
                st.erase(i);
            }
            if(kilk==3)
            {
                long long gcd=*(st.begin());
                for(auto to:st)
                {
                    gcd=__gcd(to,gcd);
                }
                cout<<gcd<<' ';
                st.erase(st.begin());
                cout<<__gcd(*(st.begin()),*(st.rbegin()))<<' ';
                cout<<*(st.rbegin())<<endl;
                return 0;
            }
        }
    }

    cout<<endl;

    amen;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)
        return cout<<1<<endl,0;
    if(n==2)
        return cout<<1<<' '<<2<<endl,0;
    if(n==3)
        return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    for(i=2; i<=n; i++)
        st.insert(i);

    res=1;

    last=1;

    kilk=n-1;

    for(i=3; i<=n; i+=2)
        cout<<1<<' ',kilk--,st.erase(i);

    if(kilk==1)
    {
        cout<<*(st.rbegin())<<endl;
        return 0;
    }

    last=2;

    while(res<=n)
    {
        res*=2;
        for(i=2; i<=n; i+=2)
        {
            if(i%res!=0)
            {
                cout<<last<<' ';
                kilk--;
                st.erase(i);
            }
            if(kilk==1)
            {
                cout<<*(st.rbegin())<<endl;
                return 0;
            }
        }
        last=res;
    }

    cout<<endl;

    amen;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)
        return cout<<1<<endl,0;
    if(n==2)
        return cout<<1<<' '<<2<<endl,0;
    if(n==3)
        return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    for(i=2; i<=n; i++)
        st.insert(i);

    res=1;

    last=1;

    kilk=n-1;

    for(i=3; i<=n; i+=2)
        cout<<1<<' ',kilk--,st.erase(i);

    last=2;

    if(kilk==3)
    {
        cout<<last<<' '<<last<<' '<<last*3<<endl;
        return 0;
    }

    n/=2;

    res=2;
    while(n>0)
    {
        if(n==3){
            cout<<res<<' '<<res<<' '<<res*3<<endl;
            return 0;
        }
        for(i=1; i<=(n+1)/2; i++)
            cout<<res<<' ';
        n/=2;
        res*=2;

        last=res;
    }

    cout<<endl;

    amen;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)return cout<<1<<endl,0;
    if(n==2)return cout<<1<<' '<<2<<endl,0;
    if(n==3)return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    res=1;

    last=1;

    kilk=n-1;

    while(res<=n){
        res*=2;
        for(i=1;i<=kilk-(n/res);i++){
            cout<<last<<' ';
        }
        last=res;
        kilk-=kilk-(n/res);
    }
    cout<<endl;

    amen;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)
        return cout<<1<<endl,0;
    if(n==2)
        return cout<<1<<' '<<2<<endl,0;
    if(n==3)
        return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    for(i=2; i<=n; i++)
        st.insert(i);

    res=1;

    last=1;

    kilk=n-1;

    for(i=3; i<=n; i+=2)
        cout<<1<<' ',kilk--,st.erase(i);

    if(kilk==1)
    {
        cout<<*(st.rbegin())<<endl;
        return 0;
    }

    last=2;

    //res=2;

    while(res<=n)
    {
        res*=2;
        for(i=2; i<=n; i+=2)
        {
            if(i%res==0 && i%(res*2)!=0)
            {
                cout<<res<<' ';
               // cout<<"NUM ="<<i<<endl;
                kilk--;
                st.erase(i);
            }
            if(kilk==1)
            {
                cout<<*(st.rbegin())<<endl;
                return 0;
            }
        }
        last=res;
    }

    cout<<endl;

    amen;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)
        return cout<<1<<endl,0;
    if(n==2)
        return cout<<1<<' '<<2<<endl,0;
    if(n==3)
        return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    for(i=2; i<=n; i++)
        st.insert(i);

    res=1;

    last=1;

    kilk=n-1;

    for(i=3; i<=n; i+=2)
        cout<<1<<' ',kilk--,st.erase(i);

    if(kilk==1)
    {
        cout<<*(st.rbegin())<<endl;
        return 0;
    }

    last=2;

    while(res<=n)
    {
        res*=2;
        for(i=2; i<=n; i+=2)
        {
            if(i%res==0)
            {
                cout<<last<<' ';
                kilk--;
                st.erase(i);
            }
            if(kilk==1)
            {
                cout<<*(st.rbegin())<<endl;
                return 0;
            }
        }
        last=res;
    }

    cout<<endl;

    amen;
}


#include <bits/stdc++.h>

using namespace std;

template<class A> using priority_queue_min=priority_queue<A,vector<A>,greater<A> >;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(),cout.tie(0)
#define pairll pair<long long,long long>
#define se second
#define fi first
#define ld long double

set<long long>st;

long long i,j,k,l,n,m,res,last,kilk;

int main()
{
    fast;

    cin>>n;

    if(n==1)
        return cout<<1<<endl,0;
    if(n==2)
        return cout<<1<<' '<<2<<endl,0;
    if(n==3)
        return cout<<1<<' '<<1<<' '<<3<<endl,0;

    cout<<1<<' ';

    for(i=2; i<=n; i++)
        st.insert(i);

    res=1;

    last=1;

    kilk=n-1;

    for(i=3; i<=n; i+=2)
        cout<<1<<' ',kilk--,st.erase(i);

    last=2;

                if(kilk==3)
            {
                cout<<last<<' '<<last<<' '<<last*3<<endl;
                return 0;
            }

    while(res<=n)
    {
        res*=2;
        for(i=2; i<=n; i+=2)
        {
            if(i%res==0 && i%(res*2)!=0)
            {
                cout<<res<<' ';
                kilk--;
                st.erase(i);
            }
            if(kilk==3)
            {
                cout<<res<<' '<<res<<' '<<res*3<<endl;
                return 0;
            }
        }

        last=res;
    }

    cout<<endl;

    amen;
}


#include<bits/stdc++.h>
using namespace std;
int dp[25];
int f[25];
int main()
{
	int n;scanf("%d",&n);
	if(n==3)
	{
		printf("1 1 3\n");
		return 0;
	}
	if(n==6)
	{
		printf("1 1 1 2 2 6\n");
		return 0;
	}
	for(int i=1;i<=(n+1)/2;i++)
		printf("1 ");

	dp[0]=1;int up=0;
	for(int i=1;;i++)
	{
		dp[i]=dp[i-1]*2;up++;
		if(dp[i]>n)
		{
			up--;break;
		}
	}
	for(int i=up;i>=1;i--)
	{
		f[i]=n/dp[i];
		for(int j=i+1;j<=up;j++)
			f[i]-=f[j];
	}
	//for(int i=1;i<=up;i++)printf("i=%d num%d\n",i,f[i]);
	for(int i=1;i<=up;i++)
	{
		for(int j=1;j<=f[i];j++)
			printf("%d ",dp[i]);
	}
	puts("");
}


//CF1059C 一开始序列是12345...n
//每次删除一个数，并把剩下的数的GCD输出
//要求最后输出要最大字典序

//我的思路：先输出奇数，因为n/2>n/3
//后面输出 2 4 8 16...n
//输出2的次数是1~n只是2的倍数的个数
//输出4的次数是1~n只是4的倍数的个数
//但是这样会WA  n=6 应该是111226 而不是111224
//我对最后一个要输出的数进行了特判，然后AC

#include<bits/stdc++.h>
using namespace std;
int dp[25];
int f[25];
vector<int>ans;
int main()
{
	int n;scanf("%d",&n);
	if(n==1)
	{
		printf("1\n");
		return 0;
	}
	for(int i=1;i<=(n+1)/2;i++)
		printf("1 ");

	dp[0]=1;int up=0;
	for(int i=1;;i++)
	{
		dp[i]=dp[i-1]*2;up++;
		if(dp[i]>n)
		{
			up--;break;
		}
	}
	for(int i=up;i>=1;i--)
	{
		f[i]=n/dp[i];
		for(int j=i+1;j<=up;j++)
			f[i]-=f[j];
	}
	//for(int i=1;i<=up;i++)printf("i=%d num%d\n",i,f[i]);
	for(int i=1;i<up;i++)
	{
		for(int j=1;j<=f[i];j++)
			printf("%d ",dp[i]);
	}

	//特判输出最后一个数
	int tmp=n;
	while(1)
	{
		if(tmp%dp[up-1]==0||tmp%dp[up]==0)
		{
			printf("%d",tmp);
			break;
		}
		tmp--;
	}

	puts("");
}


#include<bits/stdc++.h>
using namespace std;
int dp[25];
int f[25];
vector<int>ans;
int main()
{
	int n;scanf("%d",&n);
	if(n==1)
	{
		printf("1\n");
		return 0;
	}
	for(int i=1;i<=(n+1)/2;i++)
		printf("1 ");

	dp[0]=1;int up=0;
	for(int i=1;;i++)
	{
		dp[i]=dp[i-1]*2;up++;
		if(dp[i]>n)
		{
			up--;break;
		}
	}
	for(int i=up;i>=1;i--)
	{
		f[i]=n/dp[i];
		for(int j=i+1;j<=up;j++)
			f[i]-=f[j];
	}
	//for(int i=1;i<=up;i++)printf("i=%d num%d\n",i,f[i]);
	for(int i=1;i<=up;i++)
	{
		for(int j=1;j<=f[i];j++)
			ans.push_back(dp[i]);
			//printf("%d ",dp[i]);
	}
	for(int i=0;i<ans.size()-1;i++)printf("%d ",ans[i]);
	int tmp=n;
	while(1)
	{
		if(tmp%dp[up-1]==0||tmp%dp[up]==0)
		{
			printf("%d",tmp);
			break;
		}
		tmp--;
	}

	puts("");
}


#include<bits/stdc++.h>
using namespace std;
int dp[25];
int f[25];
vector<int>ans;
int main()
{
	int n;scanf("%d",&n);
	if(n==3)
	{
		printf("1 1 3\n");
		return 0;
	}
	for(int i=1;i<=(n+1)/2;i++)
		printf("1 ");

	dp[0]=1;int up=0;
	for(int i=1;;i++)
	{
		dp[i]=dp[i-1]*2;up++;
		if(dp[i]>n)
		{
			up--;break;
		}
	}
	for(int i=up;i>=1;i--)
	{
		f[i]=n/dp[i];
		for(int j=i+1;j<=up;j++)
			f[i]-=f[j];
	}
	//for(int i=1;i<=up;i++)printf("i=%d num%d\n",i,f[i]);
	for(int i=1;i<=up;i++)
	{
		for(int j=1;j<=f[i];j++)
			ans.push_back(dp[i]);
			//printf("%d ",dp[i]);
	}
	for(int i=0;i<ans.size()-1;i++)printf("%d ",ans[i]);
	int tmp=n;
	while(1)
	{
		if(tmp%dp[up-1]==0||tmp%dp[up]==0)
		{
			printf("%d",tmp);
			break;
		}
		tmp--;
	}

	puts("");
}


#include<bits/stdc++.h>
using namespace std;
int dp[25];
int f[25];
int main()
{
	int n;scanf("%d",&n);
	if(n==3)
	{
		printf("1 1 3\n");
		return 0;
	}

	for(int i=1;i<=(n+1)/2;i++)
		printf("1 ");

	dp[0]=1;int up=0;
	for(int i=1;;i++)
	{
		dp[i]=dp[i-1]*2;up++;
		if(dp[i]>n)
		{
			up--;break;
		}
	}
	for(int i=up;i>=1;i--)
	{
		f[i]=n/dp[i];
		for(int j=i+1;j<=up;j++)
			f[i]-=f[j];
	}
	//for(int i=1;i<=up;i++)printf("i=%d num%d\n",i,f[i]);
	for(int i=1;i<=up;i++)
	{
		for(int j=1;j<=f[i];j++)
			printf("%d ",dp[i]);
	}
	puts("");
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 2) return cout << "1 2" << endl, 0;
    set<int> s;
    for(i = 1; i <= n; i++) s.insert(i);
    int a = 1;
    vi ans;
    while(s.size() > 2 && a <= n){
        for(i = a; i <= n && s.size() > 2; i += (2*a)) if(s.count(i)) s.erase(i), ans.pb(a);
        a *= 2;
    }
    ans.pb(*s.begin());
    ans.pb(*s.rbegin());
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 3) return cout << 1 << " " << 1 << " " << 3 << endl, 0;
    int a = 1;
    vi ans;
    int c = n;
    while(n){
        if(n == 1) ans.pb(c), n--;
        for(i = 0; i < ceil(n/2.0); i++) ans.pb(a);
        a *= 2, n -= ceil(n/2.0);
    }
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 3) return cout << 1 << " " << 1 << " " << 3 << endl, 0;
    if(n == 1) return cout << 1 << endl, 0;
    int a = 1;
    vi ans;
    int c = n;
    while(n){
        if(n == 1){
            if(c & 1) ans.pb(c-1);
            else ans.pb(c);
            break;
        }
        for(i = 0; i < ceil(n/2.0); i++) ans.pb(a);
        a *= 2, n -= ceil(n/2.0);
    }
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 3) return cout << "1 1 3" << endl, 0;
    set<int> s;
    for(i = 1; i <= n; i++) s.insert(i);
    int a = 1;
    vi ans;
    while(a <= n){
        for(i = a; i <= n; i += (2*a)) if(s.count(i)) s.erase(i), ans.pb(a);
        a *= 2;
    }
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 1) return cout << 1 << endl, 0;
    if(n == 2) return cout << "1 2" << endl, 0;
    if(n == 3) return cout << "1 1 3" << endl, 0;
    set<int> s;
    for(i = 1; i <= n; i++) s.insert(i);
    int a = 1;
    vi ans;
    while(s.size() > 2 && a <= n){
        for(i = a; i <= n && s.size() > 2; i += (2*a)) if(s.count(i)) s.erase(i), ans.pb(a);
        a *= 2;
    }
    ans.pb(*s.begin());
    ans.pb(*s.rbegin());
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 3) return cout << "1 1 3" << endl, 0;
    set<int> s;
    for(i = 1; i <= n; i++) s.insert(i);
    int a = 1;
    vi ans;
    while(s.size() > 2 && a <= n){
        for(i = a; i <= n && s.size() > 2; i += (2*a)) if(s.count(i)) s.erase(i), ans.pb(a);
        a *= 2;
    }
    ans.pb(*s.begin());
    ans.pb(*s.rbegin());
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 1) return cout << 1 << endl, 0;
    if(n == 2) return cout << "1 2" << endl, 0;
    if(n == 3) return cout << "1 1 3" << endl, 0;
    set<int> s;
    for(i = 1; i <= n; i++) s.insert(i);
    int a = 1;
    vi ans;
    while(s.size() > 2 && a <= n){
        for(i = a; i <= n && s.size() > 2; i += (2*a)) if(s.count(i)) s.erase(i), ans.pb(a);
        a *= 2;
    }
    ans.pb(__gcd(*s.begin(), *s.rbegin()));
    ans.pb(*s.rbegin());
    show(ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    if(n == 3) return cout << 1 << " " << 1 << " " << 3 << endl, 0;
    int a = 1;
    vi ans;
    int c = n;
    while(n){
        if(n == 1){
            if(c & 1) ans.pb(c-1);
            else ans.pb(c);
            break;
        }
        for(i = 0; i < ceil(n/2.0); i++) ans.pb(a);
        a *= 2, n -= ceil(n/2.0);
    }
    show(ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

//8 16

set <int> myBag ;

void process () {
	cin >> n ;

	for (int i = 1 ; i <= n ; i ++) myBag.insert (i) ;

	if (n == 1) cout << 1 ; else if (n == 2) cout << 1 << " " << 2 ; else if (n == 3) cout << 1 << " " << 1 << " " << 3 << endl ;
	else {
		int power = 2 ;
		for ( ; power <= n ; power *= 2) {
			vector <int> needErase ; needErase.clear() ;
			for (auto temp : myBag) if (temp % power == power / 2) {
				needErase.push_back(temp) ;
				cout << power / 2 << " " ;
			}
			for (auto temp : needErase) myBag.erase(temp) ;
		}
		for (int i = 1 ; i <= myBag.size() ; i ++ ) cout << power / 2 << " " ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

// 1 2 3 4 5 6 7 8 9

void process () {
	cin >> n ;

	set <int> myBag ;
	for (int i = 1 ; i <= n ; i ++) myBag.insert (i) ;

	if (n == 1) cout << 1 ; else if (n == 2) cout << 1 << " " << 2 ; else if (n == 3) cout << 1 << " " << 1 << " " << 3 << endl ;
	else {
		int recentRes = 1 , power = 2 ;
		for ( ; power <= n ; power *= 2) {
			for (auto temp : myBag) if (temp % power == power / 2) {
				myBag.erase (temp) ;
				cout << power / 2 << " " ;
			}
		}
		cout << power / 2 ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

// 1 2 3 4 5 6 7 8 9

	set <int> myBag ;

void process () {
	cin >> n ;

	for (int i = 1 ; i <= n ; i ++) myBag.insert (i) ;

	if (n == 1) cout << 1 ; else if (n == 2) cout << 1 << " " << 2 ; else if (n == 3) cout << 1 << " " << 1 << " " << 3 << endl ;
	else {
		int power = 2 ;
		for ( ; power <= n ; power *= 2) {
			vector <int> needErase ;
			for (auto temp : myBag) if (temp % power == power / 2) {
				needErase.push_back(temp) ;
				cout << power / 2 << " " ;
			}
			for (auto temp : needErase) myBag.erase(temp) ;
		}
		cout << power / 2 ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

//n = 16
// 16

set <int> myBag ;

void process () {
	cin >> n ;

	for (int i = 1 ; i <= n ; i ++) myBag.insert (i) ;

	if (n == 1) cout << 1 ; else if (n == 2) cout << 1 << " " << 2 ; else if (n == 3) cout << 1 << " " << 1 << " " << 3 << endl ;
	else {
		int power = 2 ;
		for ( ; power <= n * 2 ; power *= 2) {
			vector <int> needErase ; needErase.clear() ;
			for (auto temp : myBag) if (temp % power == power / 2) {
				needErase.push_back(temp) ;
				cout << power / 2 << " " ;
			}
			for (auto temp : needErase) myBag.erase(temp) ;
		}

	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

set <int> myBag ;

void process () {
	cin >> n ;
	int ans = 1 ;
	while (n > 0) {
		for (int i = 1 ; i <= n ; i ++) if ((i & 1)) cout << ans << " " ;
		ans *= 2 ; n /= 2 ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

// 1 2 3 4 5 6 7 8 9

	set <int> myBag ;

void process () {
	cin >> n ;

	for (int i = 1 ; i <= n ; i ++) myBag.insert (i) ;

	if (n == 1) cout << 1 ; else if (n == 2) cout << 1 << " " << 2 ; else if (n == 3) cout << 1 << " " << 1 << " " << 3 << endl ;
	else {
		int power = 2 ;
		for ( ; power <= n ; power *= 2) {
			for (auto temp : myBag) if (temp % power == power / 2) {
				myBag.erase (temp) ;
				cout << power / 2 << " " ;
			}
		}
		cout << power / 2 ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

// 1 2 3 4 5 6 7 8 9

void process () {
	cin >> n ;

	set <int> myBag ;
	for (int i = 1 ; i <= n ; i ++) myBag.insert (i) ;

	if (n == 1) cout << 1 ; else if (n == 2) cout << 1 << " " << 2 ; else if (n == 3) cout << 1 << " " << 2 << " " << 3 << endl ;
	else {
		int recentRes = 1 , power = 2 ;
		for ( ; power <= n ; power *= 2) {
			for (auto temp : myBag) if (temp % power == power / 2) {
				myBag.erase (temp) ;
				cout << power / 2 << " " ;
			}
		}
		cout << power / 2 ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include <bits/stdc++.h>

using namespace std ;

int n ;

set <int> myBag ;

void process () {
	cin >> n ;
	int ans = 1 ;
	while (n > 0) {
		if (n == 3) {
			cout << ans << " " << ans << " " << ans * 3 << endl ;
			return ;
		}
		for (int i = 1 ; i <= n ; i ++) if ((i & 1)) cout << ans << " " ;
		ans *= 2 ; n /= 2 ;
	}
}

void code () {
	process () ;
}

int main () {
	code () ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ri register int
#define rll register long long
#define For(i,a,b) for(int i=a;i<=b;++i)
#define IOS std::ios::sync_with_stdio(false)
#define L(a) a<<1
#define R(a) a<<1|1
#define P pair<int,int>
#define re read()
#define ull unsigned long long
#define lowbit(x) ((x)&-(x))

// const int dx[4]={0,-1,0,1};
// const int dy[4]={-1,0,1,0};
const int dx[8]={-2,-1,1,2,2,1,-1,-2};
const int dy[8]={1,2,2,1,-1,-2,-2,-1};
const int inf=0x3f3f3f3f;
const int mod=10000;
const int maxn=30;
const double eps=1e-5;

inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main(){
	int n;
    cin>>n;
    int t=1;
    // if(n&1){
    //     n--;
    //     cout<<"1 ";
    // }
    // for(int i=1;i<=n/2;i++) cout<<1<<" ";
    // n/=2;
    while(n){
        if(n==3){
            cout<<t<<" "<<t<<" "<<3*t;
            return 0;
        }
        for(int i=1;i<=n/2+n%2;i++) cout<<t<<" ";
        t<<=1;n>>=1;
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,now=1;
	scanf("%d",&n);
	while(n>3)
	{
		for(int i=1;i<=((n+1)/2);++i)printf("%d ",now);
		now<<=1;n>>=1;
	}
	if(n==1)return printf("%d\n",now),0;
	else if(n==2)return printf("%d %d\n",now,now*2),0;
	else if(n==3)return printf("%d %d %d\n",now,now,now*3),0;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string.h>
#include<algorithm>
#define For(i,f,l) int pd=(f<l)*1+(l<=f)*-1;for(i=f;i!=l+pd;i+=pd)
using namespace std;
int i,j,k,m,n,now;
int main()
{
  cin>>n;
  now=1;
  while(n>3)
  {
    for(i=1;i<=(n+1)/2;i++)cout<<now<<" ";
    n/=2;
    now*=2;
  }
  if(n==3)cout<<now<<" "<<now<<" "<<now*3;
  else if(n==2)cout<<now<<" "<<now*2;
  else cout<<now;
  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int g=1;
int main(){
	scanf("%d",&n);
	while(n){
		if(n==3){
			printf("%d %d %d",g,g,g*3);
			return 0;
		}
		for(int i(1);i<=n/2+n%2;i++)printf("%d ",g);
		n=n/2;
		g=g*2;
	}
	return 0;
}
//luogu


#include<cstdio>
using namespace std;
inline int read(){int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}
inline void write(int x){if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10); putchar(x%10+'0');}
inline void writeln(int x){write(x); puts("");}
int n,t;
inline void init(){
	n=read();
}
inline void solve(){
	t=1;
	while (n>3){
		for (int i=1;i<=(n+1)>>1;i++) write(t),putchar(' ');
		n>>=1; t<<=1;
	}
	if (n==3) write(t),putchar(' '),write(t),putchar(' '),writeln(t*3);
	if (n==2) write(t),putchar(' '),writeln(2*t);
	if (n==1) writeln(t);
}
int main(){
	init(); solve();
	return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

int n,cnt=1;
int last,unit;

int main(){
	scanf("%d",&n);
	unit=(n+1)/2;
	while(n>3){
		for(int i=1;i<=unit;i++)
			printf("%d ",cnt);
		cnt<<=1;n>>=1;unit=(n+1)/2;
	}
	if(n==3) printf("%d %d %d\n",cnt,cnt,cnt*3);
	else if(n==2) printf("%d %d\n",cnt,cnt<<1);
	else if(n==1) printf("%d\n",cnt);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n;
inline void print(int AA12,int tp) {
    if(AA12==3) {printf("%d %d %d",tp,tp,tp*3);return;}
    if(AA12==2) {printf("%d %d",tp,tp*2);return;}
    if(AA12==1) {printf("%d",tp);return;}
    for(int i = 1;i<=AA12-(AA12>>1);i++) printf("%d ",tp);
    print((AA12>>1),tp<<1);

}
int main() {
    scanf("%d",&n);
    print(n,1);
}


#include <bits/stdc++.h>

int read()
{
	int sum = 0;
	char c = getchar(), f = c;
	while(c < '0' || c > '9') f = c, c = getchar();
	while(c >= '0' && c <= '9') sum = sum * 10 + c - '0', c = getchar();
	if(f == '-') sum *= -1;
	return sum;
}

int n;

void DFS(int n, int v)
{
	if(n == 0) return;
	if(n == 1)
	{
		std::cout << v << " ";
		return;
	}
	if(n == 2)
	{
		std::cout << v << " ";
		std::cout << v * 2 << " ";
		return;
	}
	if(n == 3)
	{
		std::cout << v << " ";
		std::cout << v << " ";
		std::cout << v * 3 << " ";
		return;
	}
	for(int i = 1; i <= (n + 1) / 2; i++) std::cout << v << " ";
	DFS(n / 2, v * 2);
}

int main()
{
	n = read();
	DFS(n, 1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a=1;
int main()
{
    cin>>n;
    while(n>=4)
    {
        for(int i=1;i<=(n+1)/2;i++)
            cout<<a<<" ";
        n/=2;
        a*=2;
    }
    if(n==3)
        cout<<a<<" "<<a<<" "<<3*a;
    else if (n==2)
        cout<<a<<" "<<2*a;
    else
        cout<<a;
    return 0;
}


/*Contest Code :
------------------------------------*/
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define vi vector<ll>
using namespace std;

char a[1030][1030];
int n,m;

bool can(int i,int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}
bool ch1(int i,int j)
{
    if(a[i][j] == '#' && a[i][j + 1] == '#' && a[i][j + 2] == '#')return true;
return false;
}
bool ch2(int i,int j)
{
    if(a[i][j] == '#' && a[i + 1][j] == '#' && a[i + 2][j] == '#')return true;
    return false;
}
int main()
{
    ios::sync_with_stdio(0),cin.tie();
    int n;
    cin >> n;
    if(n == 3)cout << "1 1 3";
    if(n == 2)cout << "1 2";
    if(n == 1)cout << 1 ;
    if(n < 4)return 0;
    ll c = 0,k = 1;
    while(true)
    {
        if(n == 1)return cout << k ,0;
        if(n == 2)return cout << k << " " << k * 2,0;
        if(n == 3)return cout << k << " " << k  << " " << k * 3,0;
        for(int i=0;i<n/2+n%2;i++)
            cout << k << " ";
        n /= 2,k *= 2;
    }

    return 0;
}


/*Contest Code :
------------------------------------*/
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define vi vector<ll>
using namespace std;

char a[1030][1030];
int n,m;

bool can(int i,int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}
int main()
{
    ios::sync_with_stdio(0),cin.tie();
    ll n;
    cin >> n;
    if(n == 3)cout << "1 1 3";
    if(n == 2)cout << "1 2";
    if(n == 1)cout << "1";
    if(n < 4)return 0;
    ll c = 0;
    while(true)
    {
        if(c == n / 2  && n % 2 == 0)break;
        if(c == (n / 2 + 1) && n % 2 == 1)break;
        cout << 1 << " ";
        c++;
    }

        ll x = n / 2;
        for(int i=1;i<n/2;i++)cout << 2 << " ";
       (n & 1)? cout << n - 1 : cout << n;
        return 0;

    return 0;
}


/*Contest Code :
------------------------------------*/
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ii pair<ll,ll>
#define vi vector<ll>
using namespace std;

char a[1030][1030];
int n,m;

bool can(int i,int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}
int main()
{
    ios::sync_with_stdio(0),cin.tie();
    int n;
    cin >> n;
    if(n == 3)cout << "1 1 3";
    if(n == 2)cout << "1 2";
    if(n == 1)cout << "1";
    if(n < 4)return 0;
    if(n % 2 == 1)n--,cout << 1 << " " ;
    map<int ,bool>div;
    for(int i=2;i<=n;i ++)if(n % i == 0)div[i] = true;
    for(int i=1;i<=n;i++)
        if(!div[i])cout << 1 << " " ;
    for(int i=1;i<=n;i++)
    {
        if(div[i])cout  << i << " ";
    }
    return 0;

    return 0;
}


/*Contest Code :
------------------------------------*/
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ii pair<ll,ll>
#define vi vector<ll>
using namespace std;

char a[1030][1030];
int n,m;

bool can(int i,int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}
int main()
{
    ios::sync_with_stdio(0),cin.tie();
    int n;
    cin >> n;
    if(n == 3)cout << "1 1 3";
    if(n == 2)cout << "1 2";
    if(n == 1)cout << "1";
    if(n < 4)return 0;
    int c = 0;
    while(true)
    {
        if(c == n / 2  && n % 2 == 0)break;
        if(c == (n / 2 + 1) && n % 2 == 1)break;
        cout << 1 << " ";
        c++;
    }
    if(n & 1)
        n--;

    for(int i=2; i<n/2; i++)cout << 2 << " ";
    cout << n / 2 << " ";
    cout << n;
    return 0;

    return 0;
}


/*Contest Code :
------------------------------------*/
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define vi vector<ll>
using namespace std;

char a[1030][1030];
int n,m;

bool can(int i,int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}
int main()
{
    ios::sync_with_stdio(0),cin.tie();
    ll n;
    cin >> n;
    if(n == 3)cout << "1 1 3";
    if(n == 2)cout << "1 2";
    if(n == 1)cout << "1";
    ll c = 0;
    while(true)
    {
        if(c == n / 2  && n % 2 == 0)break;
        if(c == (n / 2 + 1) && n % 2 == 1)break;
        cout << 1 << " ";
        c++;
    }

        ll x = n / 2;
        for(int i=1;i<n/2;i++)cout << 2 << " ";
       (n & 1)? cout << n - 1 : cout << n;
        return 0;

    return 0;
}


/*Contest Code :
------------------------------------*/
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define vi vector<ll>
using namespace std;

char a[1030][1030];
int n,m;

bool can(int i,int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m);
}
int main()
{
    ios::sync_with_stdio(0),cin.tie();
    ll n;
    cin >> n;
    for(int i=1;i<n;i++)cout << 1 <<  " ";
    cout << n;
    return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int n,m,k,l;
	cin>>n;
	k=2;
	while (k<=n)
	{
		for (int i=1; i<=(n+1)/k; i++)
			cout<<k/2<<" ";
		k=k*2;
	}
	cout<<n;

	return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int n,m,k,l;
	cin>>n;
	k=1; m=n;
	while (m>1)
	{
		if ((n/(k*2)) > 1)  l=n/(k*2); else l=1;
		for (int i=1; i<=m-l; i++)
			{   cout<<k<<" ";
			}
		m-= (m-l);  k=k*2;
	}  k=k/2;
	if (n==3 || n==1) cout<<n; else {
				while (n%k!=0) n--; cout<<n; }

	return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int n,m,k,l;
	cin>>n;
	k=1; m=n;
	while (m>1)
	{
		if ((n/(k*2)) > 1)  l=n/(k*2); else l=1;
		for (int i=1; i<=m-l; i++)
			{   cout<<k<<" ";
			}
		m-= (m-l);  k=k*2;
	}  k=k/2;
	if (n==3) cout<<3; else {
				while (n%k!=0) n--; cout<<n; }

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <string.h>
using namespace std;
int main ()
{
	int  n,m,ll,pred,res=0;
	int  a[1001];  bool mark[1001][1001];
	memset (mark, 0, sizeof(mark));
	cin>>n;
	if (n==1) { cout<<1; return 0; }

	//for ( int i=1; i<=(n+1)/2; i++) cout<<"1 ";
	//int ost = n/2;
	int k=1;
	while (true) {
		int b= n/k - n/(k*2);  //cout<<b<<endl;
		while (b>0) { cout<<k<<" "; b--;
		}
		k=k*2;  if ((n/k)<=1) break;
	}
	k=k/2;  //cout<<k<<endl;
	while (true) { if (n%k==0) break; n--; }
	int t=k;   //   while (k>1) { cout<<t<<" "; k--; }

	cout<<n;

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <string.h>
using namespace std;
int main ()
{
	int  n,m,ll,pred,res=0;
	int  a[1001];  bool mark[1001][1001];
	memset (mark, 0, sizeof(mark));
	cin>>n;
	if (n==1) { cout<<1; return 0; }
	for (int i=1; i<=n; i++)  { a[i]=n/i; //cout<<a[i];
	}
	//for ( int i=1; i<=(n+1)/2; i++) cout<<"1 ";
	//int ost = n/2;

	int k=1;
	while (true) {
		int b=a[k]-	a[k*2];  //cout<<b<<endl;
		while (b>0) { cout<<k<<" "; b--;
		}
		k=k*2;  if (a[k]==1) break;
	}
	k=k/2;  //cout<<k<<endl;
	while (true) { if (n%k==0) break; n--; }
	int t=k;  k=a[k]; //   while (k>1) { cout<<t<<" "; k--; }

	cout<<n;

	return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int n,m,k,l;
	cin>>n;
	k=1; m=n;
	while (m>1)
	{
		if ((n/(k*2)) > 1)  l=n/(k*2); else l=1;
		for (int i=1; i<=m-l; i++)
			{   cout<<k<<" ";
			}
		m-= (m-l);  k=k*2;
	}
	cout<<n;

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <string.h>
using namespace std;
int main ()
{
	int  n,m,ll,pred,res=0;
	int  a[1001];  bool mark[1001][1001];
	memset (mark, 0, sizeof(mark));
	cin>>n;
	if (n==1) { cout<<1; return 0; }
	for (int i=1; i<=n; i++)  { a[i]=n/i; //cout<<a[i];
	}
	//for ( int i=1; i<=(n+1)/2; i++) cout<<"1 ";
	//int ost = n/2;

	int k=1;
	while (true) {
		int b=a[k]-	a[k*2];  //cout<<b<<endl;
		while (b>0) { cout<<k<<" "; b--;
		}
		k=k*2;  if (a[k]<=1) break;
	}
	k=k/2;  //cout<<k<<endl;
	while (true) { if (n%k==0) break; n--; }
	int t=k;  k=a[k]; //   while (k>1) { cout<<t<<" "; k--; }

	cout<<n;

	return 0;
}


// C

#include<bits/stdc++.h>

using std::min;
using std::max;
using std::sort;
using std::queue;
using std::cin;
using std::cout;
using std::endl;

typedef long long ll;

const int N = 1000000;

int n;
bool a[N+3];

int main() {
    scanf("%d", &n);
    int x=1;
    while(n) {
        for(int i=1;i<=n-n/2;i++) printf("%d ",x);
        if(n==3) printf("%d\n",x*3),exit(0);
        x<<=1;
        n>>=1;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAXN 100010
using namespace std;
long long n,k;
long long a[MAXN];
long long ans[MAXN];
long long t;
int main(){
	long long i,j;
	string s;
	cin>>t;
	while(t--){
		cin>>n>>k;
		for(i=1;i<=k;i++)ans[i]=0;
		for(i=1;i<=n*k;i++){
			cin>>a[i];
		}
		long long cnt=1;
		long long fans=0;
		for(i=n*k-n/2;cnt<=k;i-=n/2+1){
			fans+=a[i];
			cnt++;
		}
		cout<<fans<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAXN 100010
using namespace std;
int n,k;
int a[MAXN];
int ans[MAXN];
int t;
int main(){
	int i,j;
	string s;
	cin>>t;
	while(t--){
		cin>>n>>k;
		for(i=1;i<=k;i++)ans[i]=0;
		for(i=1;i<=n*k;i++){
			cin>>a[i];
		}
		int cnt=1;
		int fans=0;
		for(i=n*k-n/2;cnt<=k;i-=n/2+1){
			fans+=a[i];
			cnt++;
		}
		cout<<fans<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using std::vector;
int main()
{
	int v;
	std::cin>>v;
	for(int i=0; i<v ;i++)
	{
		int n,k;
		std::cin>>n>>k;
		vector<long long int> a ;
		a.resize(n*k);
		ilong long int count=0;
		for(int j=0; j< n*k;j++)
		{
			cin>>a[j];
		}
		for(int j=1; j< k+1;j++)
		{
			int m=(n/2+1);
			count+=a[n*k-j*m];
		}

		cout<<count<<"\n";
	}

	return 0;

}