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

int s,k,t,x;
int memo[9999],ans,c[9999],p;

int make_k_bonacci(int k){
    int i,j;
    memo[k] = 1;
    for(i=k+1;;i++){
        for(j=1;j<=k;j++){
            memo[i] += memo[i-j];
            if(memo[i]<0) return i;
        }
    }
}

main(){
    scanf("%d%d",&s,&k);
    t=k;
    if(k>=32|| s<(1<<k)){
        x = __builtin_popcount(s);
        if(x==1){
            printf("2\n0 %d\n",s);
            return 0;
        }
        printf("%d\n",x);
        while(s){
            t=s&-s;
            printf("%d ",t);
            s^=t;
        }
        puts("");
        return 0;
    }
    int z = make_k_bonacci(k);
    t=s;
    while(z--&&s){
        if(s>=memo[z]&&memo[z]!=t){
            ans++;
            c[p++]=memo[z];
            s-=memo[z];
        }
    }
    printf("%d\n",ans);
    while(p--)printf("%d ",c[p]);
    puts("");
    return 0;
}

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

int main(void){
  int fib[45]={0},stock[45]={0};
  int s,k,i,n,sum=0,num=0;
  scanf("%d %d",&s,&k);
  for(i=0;i==0||fib[i-1]<=s;i++){
    if(i<=1) fib[i]=1;
    else if(i<=k) fib[i]=sum;
    else{
      sum-=fib[i-k-1];
      fib[i]=sum;
    }
    //printf("%d %d\n",i,fib[i]);
    sum+=fib[i];
    //printf("sum:%d\n",sum);
  }
  //printf("i:%d\n",i);
  n=i-2;
  //printf("n:%d %d\n",n,fib[n]);
  for(i=n;i>=0;i--){
    if(fib[i]<=s){
      stock[num++]=fib[i];
      s-=fib[i];
      if(s==0) break;
    }
  }
  if(num==1) fib[num++]=0;
  printf("%d\n",num);
  for(i=num-1;i>=0;i--){
    printf("%d",stock[i]);
    putchar((i>0)?' ':'\n');
  }
  return 0;
}

 #include <stdio.h>

 long kf[1000];
 long ch[1000];

 int main(){
     long s, k;
     int m=1;
     long tmp;
     int i, j;
     int n;
     int alone=0;
     scanf ("%ld%ld", &s, &k);
     kf[1]=1;
     i=1;
     while (kf[i]<=s){
         i++;
         tmp=i-k;
         if (tmp<0) tmp=0;
         for (j=i-1; j>=tmp; j--)
            kf[i]+=kf[j];
     }
     while (s>0){
         while (kf[i]>s) i--;
         s=s-kf[i];
         ch[m]=kf[i];
         m++;
         i--;
     }
//   printf ("i - %d, alone - %d, s - %ld, m - %d\n", i, alone, s, m);
     if (m==2) alone++;
     if (alone){
         printf ("%d\n", m);
        for (i=1; i<=m; i++)
            printf ("%ld ", ch[i]);
    }
    else{
        printf ("%d\n", m-1);
        for (i=1; i<m; i++)
            printf ("%ld ", ch[i]);
    }
     printf ("\n");
     return 0;
 }

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

int S, K, i;
long long int F[100];
int Counter;
int Ans[100];
int k;

int main(){
    while(~scanf("%d%d", &S, &K)){
        F[0] = 0;
        F[1] = 1;
        F[2] = 1;

        k=K;
        if (k>30) k = 30;

        for (i=3; F[i-1]<(1<<(k-1)); i++) F[i] = 1<<(i-2);

        for ( ; F[i-1]<S; i++) F[i] = 2*F[i-1] - F[i-k-1];
        i--;
        Counter = 0;
        while(i){
            if (S==0) break;
            if (F[i]>S){
                i--;
                continue;
            }
            Ans[Counter] = F[i];
            Counter++;
            S -= F[i];
            i--;
        }
        if (Counter==1){
            Counter = 2;
            Ans[1] = 0;
        }
        printf("%d\n", Counter);
        printf("%d", Ans[0]);
        for (i=1; i<Counter; i++) printf(" %d", Ans[i]);
        putchar(10);
    }

    return 0;
}

//In the name of God
#include <stdio.h>

#define int long long

int s,k,sone;

int f[10000];
int ans[10000];

void make()
{
  sone=s;
  int sum=0;
  int i;
  int last=0;
  for(i=k;;i++)
    {
      if(i==k)
	{f[i-k+10]=sum=1; continue;}
      f[i-k+10]=sum;
      //      printf("f[%lld]=%lld\n",i,f[i]);
      if(f[i-k+10]>s) break;
      sum+=f[i-k+10];
      if(i-k-k+10>=0)
	sum-=f[i-k-k+10];
    }
  int index=0;
  for(;i>=0;i--)
    {
      if(f[i-k+10]<=s)
	s-=f[i-k+10],ans[index++]=f[i-k+10];
      if(f[i-k+10]==0) break;
    }
  printf("%lld\n",index);
  for(i=0;i<index;++i)
    printf("%lld ",ans[i]);
}

main()
{
  scanf("%lld%lld",&s,&k);
  make();
  return 0;
}

#include<stdio.h>
#include<stdlib.h>
long long int a[50];
int main()
{
    int i,j,s,k,n;
    scanf("%d%d",&s,&k);
    long long int sum=0;
    //make atmost 50 entries in array a
    a[0]=1;
    for(i=1;i<50;i++)
    {
        sum=0;
        for(j=i-1;j>=i-k;j--)
        {
            if(j<0)break;
            sum+=a[j];
        }
        if(sum>2000000000)break;
        else
        a[i]=sum;
    }
    n=i;
    long long int sol[50];
    int z=0;
    while(s>0)
    {
        i=0;
        while(a[i]<=s)
        i++;
        s=s-a[i-1];
        sol[z++]=a[i-1];
    }
    if(z==1)
    {
        printf("2\n");
        printf("0 %lld\n",sol[0]);
    }
    else
    {
        printf("%d\n",z);
        for(i=0;i<z-1;i++)
        printf("%lld ",sol[i]);
        printf("%lld\n",sol[i]);
    }

    return(0);
}

#include <stdio.h>

int k, s;
int nkb, kb[1024];
int nres, res[1024];

int main()
{
    int i, j;
    scanf("%d%d", &s, &k);
    kb[0] = 1;
    for ( i = 1; ; ++i )
    {
        long long sum = 0;
        for ( j = 0; ++j <= k && j <= i; )
            sum += kb[i - j];
        if ( s < sum )
            break;
        kb[i] = sum;
    }
    nkb = i;
    for ( nres = 0, i = nkb, j = s; --i >= 0 && j > 0; )
    {
        if ( j >= kb[i] )
        {
            j -= kb[i];
            res[nres++] = kb[i];
        }
    }
    if ( nres == 1 )
        res[nres++] = 0;
    printf("%d\n", nres);
    while ( --nres > 0 )
        printf("%d ", res[nres]);
    printf("%d\n", res[nres]);
    return 0;
}

/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct home{
	int tasks[100];
	int nt;
};
struct card{
	int val;
	char suit;
	int id;
};
struct task{
	int done;
	int id;
	int home;
	int pre[200];
	int np;
};
struct bstnode{
	int id;
	int visit;
	struct bstnode *left;
	struct bstnode *right;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[202];
	int wei[200];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
long long GCD(long long a,long long b){
	if(a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int f(long long a, long long arr[], int n){
	if(a<=10000000){
		arr[n++]=a;
		return n;
	}
	int i;
	int k;
	for(i=sqrt(a)+1;i>1;i--)
		if(a%i==0){
			k=f(a/i,arr,n);
			return f(i,arr,k);
		}
}
void merge(int *a,int l,int q,int n){
	int n1=q-l+1;
	int i,j,k;
	int n2=n-q;
	int L[n1+1];
	int R[n2+1];
	for(i=0;i<n1;i++)
		L[i]=a[l+i];
	for(i=0;i<n2;i++)
		R[i]=a[q+i+1];
	L[n1]=100002;
	R[n2]=100002;
	i=0;
	j=0;
	for(k=l;k<=n;k++)
		if(L[i]<=R[j]){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
}
void mergesort(int *a,int l,int n){
	if(n>l){
		int q=(l+n)/2;
		mergesort(a,l,q);
		mergesort(a,q+1,n);
		merge(a,l,q,n);
	}
}
void prime(long long n,long long *a){
	int i=2;
	int flag=0;
	while(i<(sqrt(n)+1)){
		if(n%i==0){
			a[i]++;
			n/=i;
			i=2;
			flag=1;
		}else
			i++;
	}
	if(n>1)
		a[n]++;
}
struct task **dup1(struct task *t[],int n){
	struct task **dup=(struct task **)malloc(sizeof(struct bstnode *)*n);
	int i,j;
	for(i=0;i<n;i++){
		dup[i]=(struct task *)malloc(sizeof(struct task));
		dup[i]->home=t[i]->home;
		dup[i]->done=t[i]->done;
		dup[i]->id=t[i]->id;
		dup[i]->np=t[i]->np;
		for(j=0;j<t[i]->np;j++)
			dup[i]->pre[j]=t[i]->pre[j];
	}
	return dup;
}
struct home homes[3];
void make(struct task *t[],struct bstnode *root,int i,int n){
	int idx,idx2;
	int j;
	root->visit=0;
	struct task **dup=dup1(t,n);
	root->id=dup[i]->home;
	for(idx=0;idx<homes[dup[i]->home-1].nt;idx++)    //doing all the tasks that has no prereq
		if(dup[homes[dup[i]->home-1].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home-1].tasks[idx]-1]->done==0){
			dup[homes[dup[i]->home-1].tasks[idx]-1]->done=1;
			for(idx2=0;idx2<n;idx2++)
					for(j=0;dup[idx2]->pre[j]!=0;j++)
						if(dup[idx2]->pre[j]==dup[homes[dup[i]->home-1].tasks[idx]-1]->id){
							dup[idx2]->pre[j]=-1;
							dup[idx2]->np--;
						}
		}
	for(idx=0;idx<homes[dup[i]->home%3].nt;idx++)    //checking nei
		if(dup[homes[dup[i]->home%3].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home%3].tasks[idx]-1]->done==0){
			root->left=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->left->left=NULL;
			root->left->right=NULL;
			make(dup,root->left,dup[homes[dup[i]->home%3].tasks[idx]-1]->id-1,n);
		}
	int home;
	if(dup[i]->home==1)
		home=2;
	else
		home=dup[i]->home-2;
	for(idx=0;idx<homes[home].nt;idx++)		//checking nei
		if(dup[homes[home].tasks[idx]-1]->np==0 && dup[homes[home].tasks[idx]-1]->done==0){
			root->right=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->right->right=NULL;
			root->right->left=NULL;
			make(dup,root->right,dup[homes[home].tasks[idx]-1]->id-1,n);
		}

}
void chg(struct bstnode a){
	if(a.id==3)
		printf("%d",a.id);
	else{
		a.id=3;
		chg(a);
	}
}
int cal(struct bstnode *root,int cost){
	if(root==NULL)
		return cost;
	int left=0,right=0;
	if(root->left!=NULL)
		left=cal(root->left,cost+1);
	if(root->right!=NULL)
		right=cal(root->right,cost+2);
	if(left==0 && right==0)
		return cost;
	if(left==0 && right!=0)
		return right;
	if(right==0 && left!=0)
		return left;
	return (left>right)?right:left;
}
void print(struct bstnode *root, int i){
	if(root==NULL)
		return;
	/*if(root->visit)
		return ;
	root->visit=1;*/
	print(root->left,1);
	if(i==1)
		printf("left:");
	else if(i==0)
		printf("root:");
	else if(i==2)
		printf("right:");
	printf("%d ",root->id);
	print(root->right,2);
}
/*long long a[10000000];
long long b[10000000];
long long p[10000000];
long long primes[700000];*/
void prin(int *a,int num,int n){
	int i;
	if(num==0 || num==1 || num==2){
		printf("%d ",num);
		return ;
	}
	for(i=n-1;i>=0 && a[i]>num;i--);
	printf("%d ",a[i]);
	prin(a,n-a[i],n);
}
long long a[10000];
long long l[10000];
main(){
	char s[20];
	int i=0,j,idx=0;
	getword(s,20);
	long long num=atll(s);
	getword(s,20);
	long long k=atll(s);
	if(num==1){
		printf("2\n1 0");
		return 0;
	}
	if(num==2){
		printf("2\n2 0");
		return 0;
	}
	long long sum=1;
	a[i++]=0;
	a[i++]=1;
	for(;sum<=num;i++){
		a[i]=sum;
		if(i-k>=0)
			sum-=a[i-k];
		sum+=a[i];
	}
	j=i-1;
	while(num>2){
		l[idx++]=a[j];
		num-=a[j];
		for(j=i-1;j>=0 && a[j]>num;j--);
	}
	l[idx++]=num;
	printf("%d\n",idx);
	for(j=0;j<idx;j++)
		printf("%I64d ",l[j]);
	return 0;
}

#include <stdio.h>

int k, s;
int nkb, kb[1024];
int nres, res[1024];

int main()
{
	int i, j;
	scanf("%d%d", &s, &k);
	if ( s == 1 )
	{
		puts("0 1");
		return 0;
	}
	kb[0] = 1;
	for ( i = 1; ; ++i )
	{
		long long sum = 0;
		for ( j = 0; ++j <= k && j <= i; )
			sum += kb[i - j];
		if ( sum >= s )
			break;
		kb[i] = sum;
	}
	nkb = i;
	for ( nres = 0, i = nkb, j = s; --i >= 0 && j > 0; )
	{
		if ( j >= kb[i] )
		{
			j -= kb[i];
			res[nres++] = kb[i];
		}
	}
	printf("%d\n", nres);
	while ( --nres > 0 )
		printf("%d ", res[nres]);
	printf("%d\n", res[nres]);
	return 0;
}

#include <stdio.h>

int k, s;
int nkb, kb[1024];
int nres, res[1024];

int main()
{
    int i, j;
    scanf("%d%d", &s, &k);
    if ( s == 1 )
    {
        puts("0 1");
        return 0;
    }
    kb[0] = 1;
    for ( i = 1; ; ++i )
    {
        long long sum = 0;
        for ( j = 0; ++j <= k && j <= i; )
            sum += kb[i - j];
        if ( s < sum )
            break;
        kb[i] = sum;
    }
    nkb = i;
    for ( nres = 0, i = nkb, j = s; --i >= 0 && j > 0; )
    {
        if ( j >= kb[i] )
        {
            j -= kb[i];
            res[nres++] = kb[i];
        }
    }
    if ( nres == 1 )
        res[nres++] = 0;
    printf("%d\n", nres);
    while ( --nres > 0 )
        printf("%d ", res[nres]);
    printf("%d\n", res[nres]);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f-*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX  100
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;

int main()
{
   int cases;
   int i,j,n;
   int a[MAX];
   scanf("%d",&n);
   int ans=0;
   //printf("n is %d\n",n&(n-1));
   if((n&(n-1))==0){
      printf("%d\n%d %d\n",2,0,n);
      return 0;
   }
   int fact=1;
   while(2*fact<=n) fact*=2;
   while(fact>=1){
      if(n>=fact)
         a[ans++]=fact;
      n%=fact;
      fact/=2;
   }
   printf("%d\n",ans);
   for(i=0;i<ans;++i)
      printf("%d ",a[i]);
   printf("\n");

   return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f-*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX  100
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;

int main()
{
   int cases;
   int i,j,n;
   int a[MAX];
   scanf("%d",&n);
   int ans=0;
   int fact=1;
//   if(n&(n-1)==0){
      printf("%d\n%d %d\n",2,0,n);
      return 0;
  // }

   while(n){
      if(n>fact){
         a[ans]=fact;
         ans++;
         n-=fact;
      }
      fact*=2;
   }
   printf("%d\n",ans);
   for(i=0;i<n;++i)
      printf("%d ",a[i]);
   printf("\n");

   return 0;
}

/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct home{
	int tasks[100];
	int nt;
};
struct card{
	int val;
	char suit;
	int id;
};
struct task{
	int done;
	int id;
	int home;
	int pre[200];
	int np;
};
struct bstnode{
	int id;
	int visit;
	struct bstnode *left;
	struct bstnode *right;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[202];
	int wei[200];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
long long GCD(long long a,long long b){
	if(a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int f(long long a, long long arr[], int n){
	if(a<=10000000){
		arr[n++]=a;
		return n;
	}
	int i;
	int k;
	for(i=sqrt(a)+1;i>1;i--)
		if(a%i==0){
			k=f(a/i,arr,n);
			return f(i,arr,k);
		}
}
void merge(int *a,int l,int q,int n){
	int n1=q-l+1;
	int i,j,k;
	int n2=n-q;
	int L[n1+1];
	int R[n2+1];
	for(i=0;i<n1;i++)
		L[i]=a[l+i];
	for(i=0;i<n2;i++)
		R[i]=a[q+i+1];
	L[n1]=100002;
	R[n2]=100002;
	i=0;
	j=0;
	for(k=l;k<=n;k++)
		if(L[i]<=R[j]){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
}
void mergesort(int *a,int l,int n){
	if(n>l){
		int q=(l+n)/2;
		mergesort(a,l,q);
		mergesort(a,q+1,n);
		merge(a,l,q,n);
	}
}
void prime(long long n,long long *a){
	int i=2;
	int flag=0;
	while(i<(sqrt(n)+1)){
		if(n%i==0){
			a[i]++;
			n/=i;
			i=2;
			flag=1;
		}else
			i++;
	}
	if(n>1)
		a[n]++;
}
struct task **dup1(struct task *t[],int n){
	struct task **dup=(struct task **)malloc(sizeof(struct bstnode *)*n);
	int i,j;
	for(i=0;i<n;i++){
		dup[i]=(struct task *)malloc(sizeof(struct task));
		dup[i]->home=t[i]->home;
		dup[i]->done=t[i]->done;
		dup[i]->id=t[i]->id;
		dup[i]->np=t[i]->np;
		for(j=0;j<t[i]->np;j++)
			dup[i]->pre[j]=t[i]->pre[j];
	}
	return dup;
}
struct home homes[3];
void make(struct task *t[],struct bstnode *root,int i,int n){
	int idx,idx2;
	int j;
	root->visit=0;
	struct task **dup=dup1(t,n);
	root->id=dup[i]->home;
	for(idx=0;idx<homes[dup[i]->home-1].nt;idx++)    //doing all the tasks that has no prereq
		if(dup[homes[dup[i]->home-1].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home-1].tasks[idx]-1]->done==0){
			dup[homes[dup[i]->home-1].tasks[idx]-1]->done=1;
			for(idx2=0;idx2<n;idx2++)
					for(j=0;dup[idx2]->pre[j]!=0;j++)
						if(dup[idx2]->pre[j]==dup[homes[dup[i]->home-1].tasks[idx]-1]->id){
							dup[idx2]->pre[j]=-1;
							dup[idx2]->np--;
						}
		}
	for(idx=0;idx<homes[dup[i]->home%3].nt;idx++)    //checking nei
		if(dup[homes[dup[i]->home%3].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home%3].tasks[idx]-1]->done==0){
			root->left=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->left->left=NULL;
			root->left->right=NULL;
			make(dup,root->left,dup[homes[dup[i]->home%3].tasks[idx]-1]->id-1,n);
		}
	int home;
	if(dup[i]->home==1)
		home=2;
	else
		home=dup[i]->home-2;
	for(idx=0;idx<homes[home].nt;idx++)		//checking nei
		if(dup[homes[home].tasks[idx]-1]->np==0 && dup[homes[home].tasks[idx]-1]->done==0){
			root->right=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->right->right=NULL;
			root->right->left=NULL;
			make(dup,root->right,dup[homes[home].tasks[idx]-1]->id-1,n);
		}

}
void chg(struct bstnode a){
	if(a.id==3)
		printf("%d",a.id);
	else{
		a.id=3;
		chg(a);
	}
}
int cal(struct bstnode *root,int cost){
	if(root==NULL)
		return cost;
	int left=0,right=0;
	if(root->left!=NULL)
		left=cal(root->left,cost+1);
	if(root->right!=NULL)
		right=cal(root->right,cost+2);
	if(left==0 && right==0)
		return cost;
	if(left==0 && right!=0)
		return right;
	if(right==0 && left!=0)
		return left;
	return (left>right)?right:left;
}
void print(struct bstnode *root, int i){
	if(root==NULL)
		return;
	/*if(root->visit)
		return ;
	root->visit=1;*/
	print(root->left,1);
	if(i==1)
		printf("left:");
	else if(i==0)
		printf("root:");
	else if(i==2)
		printf("right:");
	printf("%d ",root->id);
	print(root->right,2);
}
/*long long a[10000000];
long long b[10000000];
long long p[10000000];
long long primes[700000];*/
void prin(int *a,int num,int n){
	int i;
	if(num==0 || num==1 || num==2){
		printf("%d ",num);
		return ;
	}
	for(i=n-1;i>=0 && a[i]>num;i--);
	printf("%d ",a[i]);
	prin(a,n-a[i],n);
}
long long a[10000];
long long l[10000];
main(){
	char s[20];
	int i=0,j,idx=0;
	getword(s,20);
	long long num=atll(s);
	getword(s,20);
	long long k=atll(s);
	if(num==1){
		printf("2\n1 0");
		return 0;
	}
	if(num==2){
		printf("2\n2 0");
		return 0;
	}
	long long sum=1;
	a[i++]=0;
	a[i++]=1;
	for(;sum<num;i++){
		a[i]=sum;
		if(i-k>=0)
			sum-=a[i-k];
		sum+=a[i];
	}
	j=i-1;
	while(num>2){
		l[idx++]=a[j];
		num-=a[j];
		for(j=i-1;j>=0 && a[j]>num;j--);
	}
	l[idx++]=num;
	printf("%d\n",idx);
	for(j=0;j<idx;j++)
		printf("%I64d ",l[j]);
	return 0;
}

/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct home{
	int tasks[100];
	int nt;
};
struct card{
	int val;
	char suit;
	int id;
};
struct task{
	int done;
	int id;
	int home;
	int pre[200];
	int np;
};
struct bstnode{
	int id;
	int visit;
	struct bstnode *left;
	struct bstnode *right;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[202];
	int wei[200];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
long long GCD(long long a,long long b){
	if(a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int f(long long a, long long arr[], int n){
	if(a<=10000000){
		arr[n++]=a;
		return n;
	}
	int i;
	int k;
	for(i=sqrt(a)+1;i>1;i--)
		if(a%i==0){
			k=f(a/i,arr,n);
			return f(i,arr,k);
		}
}
void merge(int *a,int l,int q,int n){
	int n1=q-l+1;
	int i,j,k;
	int n2=n-q;
	int L[n1+1];
	int R[n2+1];
	for(i=0;i<n1;i++)
		L[i]=a[l+i];
	for(i=0;i<n2;i++)
		R[i]=a[q+i+1];
	L[n1]=100002;
	R[n2]=100002;
	i=0;
	j=0;
	for(k=l;k<=n;k++)
		if(L[i]<=R[j]){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
}
void mergesort(int *a,int l,int n){
	if(n>l){
		int q=(l+n)/2;
		mergesort(a,l,q);
		mergesort(a,q+1,n);
		merge(a,l,q,n);
	}
}
void prime(long long n,long long *a){
	int i=2;
	int flag=0;
	while(i<(sqrt(n)+1)){
		if(n%i==0){
			a[i]++;
			n/=i;
			i=2;
			flag=1;
		}else
			i++;
	}
	if(n>1)
		a[n]++;
}
struct task **dup1(struct task *t[],int n){
	struct task **dup=(struct task **)malloc(sizeof(struct bstnode *)*n);
	int i,j;
	for(i=0;i<n;i++){
		dup[i]=(struct task *)malloc(sizeof(struct task));
		dup[i]->home=t[i]->home;
		dup[i]->done=t[i]->done;
		dup[i]->id=t[i]->id;
		dup[i]->np=t[i]->np;
		for(j=0;j<t[i]->np;j++)
			dup[i]->pre[j]=t[i]->pre[j];
	}
	return dup;
}
struct home homes[3];
void make(struct task *t[],struct bstnode *root,int i,int n){
	int idx,idx2;
	int j;
	root->visit=0;
	struct task **dup=dup1(t,n);
	root->id=dup[i]->home;
	for(idx=0;idx<homes[dup[i]->home-1].nt;idx++)    //doing all the tasks that has no prereq
		if(dup[homes[dup[i]->home-1].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home-1].tasks[idx]-1]->done==0){
			dup[homes[dup[i]->home-1].tasks[idx]-1]->done=1;
			for(idx2=0;idx2<n;idx2++)
					for(j=0;dup[idx2]->pre[j]!=0;j++)
						if(dup[idx2]->pre[j]==dup[homes[dup[i]->home-1].tasks[idx]-1]->id){
							dup[idx2]->pre[j]=-1;
							dup[idx2]->np--;
						}
		}
	for(idx=0;idx<homes[dup[i]->home%3].nt;idx++)    //checking nei
		if(dup[homes[dup[i]->home%3].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home%3].tasks[idx]-1]->done==0){
			root->left=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->left->left=NULL;
			root->left->right=NULL;
			make(dup,root->left,dup[homes[dup[i]->home%3].tasks[idx]-1]->id-1,n);
		}
	int home;
	if(dup[i]->home==1)
		home=2;
	else
		home=dup[i]->home-2;
	for(idx=0;idx<homes[home].nt;idx++)		//checking nei
		if(dup[homes[home].tasks[idx]-1]->np==0 && dup[homes[home].tasks[idx]-1]->done==0){
			root->right=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->right->right=NULL;
			root->right->left=NULL;
			make(dup,root->right,dup[homes[home].tasks[idx]-1]->id-1,n);
		}

}
void chg(struct bstnode a){
	if(a.id==3)
		printf("%d",a.id);
	else{
		a.id=3;
		chg(a);
	}
}
int cal(struct bstnode *root,int cost){
	if(root==NULL)
		return cost;
	int left=0,right=0;
	if(root->left!=NULL)
		left=cal(root->left,cost+1);
	if(root->right!=NULL)
		right=cal(root->right,cost+2);
	if(left==0 && right==0)
		return cost;
	if(left==0 && right!=0)
		return right;
	if(right==0 && left!=0)
		return left;
	return (left>right)?right:left;
}
void print(struct bstnode *root, int i){
	if(root==NULL)
		return;
	/*if(root->visit)
		return ;
	root->visit=1;*/
	print(root->left,1);
	if(i==1)
		printf("left:");
	else if(i==0)
		printf("root:");
	else if(i==2)
		printf("right:");
	printf("%d ",root->id);
	print(root->right,2);
}
/*long long a[10000000];
long long b[10000000];
long long p[10000000];
long long primes[700000];*/
void prin(int *a,int num,int n){
	int i;
	if(num==0 || num==1 || num==2){
		printf("%d ",num);
		return ;
	}
	for(i=n-1;i>=0 && a[i]>num;i--);
	printf("%d ",a[i]);
	prin(a,n-a[i],n);
}
int a[10000];
int l[10000];
main(){
	char s[20];
	int i=0,j,idx=0;
	getword(s,20);
	int num=atoi(s);
	getword(s,20);
	int k=atoi(s);
	if(num==1){
		printf("2\n1 0");
		return 0;
	}
	if(num==2){
		printf("2\n2 0");
		return 0;
	}
	int sum=1;
	a[i++]=0;
	a[i++]=1;
	for(;sum<num;i++){
		a[i]=sum;
		if(i-k>=0)
			sum-=a[i-k];
		sum+=a[i];
	}
	//printf("%d ",i);
	j=i-1;
	while(num>2){
		l[idx++]=a[j];
		num-=a[j];
		for(j=i-1;j>=0 && a[j]>num;j--);
	}
	l[idx++]=num;
	printf("%d\n",idx);
	for(j=0;j<idx;j++)
		printf("%d ",l[j]);
	return 0;
}

/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct home{
	int tasks[100];
	int nt;
};
struct card{
	int val;
	char suit;
	int id;
};
struct task{
	int done;
	int id;
	int home;
	int pre[200];
	int np;
};
struct bstnode{
	int id;
	int visit;
	struct bstnode *left;
	struct bstnode *right;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[202];
	int wei[200];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
long long GCD(long long a,long long b){
	if(a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int f(long long a, long long arr[], int n){
	if(a<=10000000){
		arr[n++]=a;
		return n;
	}
	int i;
	int k;
	for(i=sqrt(a)+1;i>1;i--)
		if(a%i==0){
			k=f(a/i,arr,n);
			return f(i,arr,k);
		}
}
void merge(int *a,int l,int q,int n){
	int n1=q-l+1;
	int i,j,k;
	int n2=n-q;
	int L[n1+1];
	int R[n2+1];
	for(i=0;i<n1;i++)
		L[i]=a[l+i];
	for(i=0;i<n2;i++)
		R[i]=a[q+i+1];
	L[n1]=100002;
	R[n2]=100002;
	i=0;
	j=0;
	for(k=l;k<=n;k++)
		if(L[i]<=R[j]){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
}
void mergesort(int *a,int l,int n){
	if(n>l){
		int q=(l+n)/2;
		mergesort(a,l,q);
		mergesort(a,q+1,n);
		merge(a,l,q,n);
	}
}
void prime(long long n,long long *a){
	int i=2;
	int flag=0;
	while(i<(sqrt(n)+1)){
		if(n%i==0){
			a[i]++;
			n/=i;
			i=2;
			flag=1;
		}else
			i++;
	}
	if(n>1)
		a[n]++;
}
struct task **dup1(struct task *t[],int n){
	struct task **dup=(struct task **)malloc(sizeof(struct bstnode *)*n);
	int i,j;
	for(i=0;i<n;i++){
		dup[i]=(struct task *)malloc(sizeof(struct task));
		dup[i]->home=t[i]->home;
		dup[i]->done=t[i]->done;
		dup[i]->id=t[i]->id;
		dup[i]->np=t[i]->np;
		for(j=0;j<t[i]->np;j++)
			dup[i]->pre[j]=t[i]->pre[j];
	}
	return dup;
}
struct home homes[3];
void make(struct task *t[],struct bstnode *root,int i,int n){
	int idx,idx2;
	int j;
	root->visit=0;
	struct task **dup=dup1(t,n);
	root->id=dup[i]->home;
	for(idx=0;idx<homes[dup[i]->home-1].nt;idx++)    //doing all the tasks that has no prereq
		if(dup[homes[dup[i]->home-1].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home-1].tasks[idx]-1]->done==0){
			dup[homes[dup[i]->home-1].tasks[idx]-1]->done=1;
			for(idx2=0;idx2<n;idx2++)
					for(j=0;dup[idx2]->pre[j]!=0;j++)
						if(dup[idx2]->pre[j]==dup[homes[dup[i]->home-1].tasks[idx]-1]->id){
							dup[idx2]->pre[j]=-1;
							dup[idx2]->np--;
						}
		}
	for(idx=0;idx<homes[dup[i]->home%3].nt;idx++)    //checking nei
		if(dup[homes[dup[i]->home%3].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home%3].tasks[idx]-1]->done==0){
			root->left=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->left->left=NULL;
			root->left->right=NULL;
			make(dup,root->left,dup[homes[dup[i]->home%3].tasks[idx]-1]->id-1,n);
		}
	int home;
	if(dup[i]->home==1)
		home=2;
	else
		home=dup[i]->home-2;
	for(idx=0;idx<homes[home].nt;idx++)		//checking nei
		if(dup[homes[home].tasks[idx]-1]->np==0 && dup[homes[home].tasks[idx]-1]->done==0){
			root->right=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->right->right=NULL;
			root->right->left=NULL;
			make(dup,root->right,dup[homes[home].tasks[idx]-1]->id-1,n);
		}

}
void chg(struct bstnode a){
	if(a.id==3)
		printf("%d",a.id);
	else{
		a.id=3;
		chg(a);
	}
}
int cal(struct bstnode *root,int cost){
	if(root==NULL)
		return cost;
	int left=0,right=0;
	if(root->left!=NULL)
		left=cal(root->left,cost+1);
	if(root->right!=NULL)
		right=cal(root->right,cost+2);
	if(left==0 && right==0)
		return cost;
	if(left==0 && right!=0)
		return right;
	if(right==0 && left!=0)
		return left;
	return (left>right)?right:left;
}
void print(struct bstnode *root, int i){
	if(root==NULL)
		return;
	/*if(root->visit)
		return ;
	root->visit=1;*/
	print(root->left,1);
	if(i==1)
		printf("left:");
	else if(i==0)
		printf("root:");
	else if(i==2)
		printf("right:");
	printf("%d ",root->id);
	print(root->right,2);
}
/*long long a[10000000];
long long b[10000000];
long long p[10000000];
long long primes[700000];*/
void prin(int *a,int num,int n){
	int i;
	if(num==0 || num==1 || num==2){
		printf("%d ",num);
		return ;
	}
	for(i=n-1;i>=0 && a[i]>num;i--);
	printf("%d ",a[i]);
	prin(a,n-a[i],n);
}
long long a[10000];
long long l[10000];
main(){
	char s[20];
	int i=0,j,idx=0;
	getword(s,20);
	long long num=atll(s);
	getword(s,20);
	long long k=atll(s);
	if(num==1){
		printf("2\n1 0");
		return 0;
	}
	if(num==2){
		printf("2\n2 0");
		return 0;
	}
	long long sum=1;
	a[i++]=0;
	a[i++]=1;
	for(;sum<num;i++){
		a[i]=sum;
		if(i-k>=0)
			sum-=a[i-k];
		sum+=a[i];
	}
	j=i-1;
	while(num>2){
		l[idx++]=a[j];
		num-=a[j];
		for(j=i-1;j>=0 && a[j]>num;j--);
	}
	l[idx++]=num;
	if(idx==1){
		printf("2\n%I64d 0",l[0]);
		return 0;
	}
	printf("%d\n",idx);
	for(j=0;j<idx;j++)
		printf("%I64d ",l[j]);
	return 0;
}

/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct home{
	int tasks[100];
	int nt;
};
struct card{
	int val;
	char suit;
	int id;
};
struct task{
	int done;
	int id;
	int home;
	int pre[200];
	int np;
};
struct bstnode{
	int id;
	int visit;
	struct bstnode *left;
	struct bstnode *right;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[202];
	int wei[200];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
long long GCD(long long a,long long b){
	if(a%b==0)
		return b;
	else
		return GCD(b,a%b);
}
int f(long long a, long long arr[], int n){
	if(a<=10000000){
		arr[n++]=a;
		return n;
	}
	int i;
	int k;
	for(i=sqrt(a)+1;i>1;i--)
		if(a%i==0){
			k=f(a/i,arr,n);
			return f(i,arr,k);
		}
}
void merge(int *a,int l,int q,int n){
	int n1=q-l+1;
	int i,j,k;
	int n2=n-q;
	int L[n1+1];
	int R[n2+1];
	for(i=0;i<n1;i++)
		L[i]=a[l+i];
	for(i=0;i<n2;i++)
		R[i]=a[q+i+1];
	L[n1]=100002;
	R[n2]=100002;
	i=0;
	j=0;
	for(k=l;k<=n;k++)
		if(L[i]<=R[j]){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
}
void mergesort(int *a,int l,int n){
	if(n>l){
		int q=(l+n)/2;
		mergesort(a,l,q);
		mergesort(a,q+1,n);
		merge(a,l,q,n);
	}
}
void prime(long long n,long long *a){
	int i=2;
	int flag=0;
	while(i<(sqrt(n)+1)){
		if(n%i==0){
			a[i]++;
			n/=i;
			i=2;
			flag=1;
		}else
			i++;
	}
	if(n>1)
		a[n]++;
}
struct task **dup1(struct task *t[],int n){
	struct task **dup=(struct task **)malloc(sizeof(struct bstnode *)*n);
	int i,j;
	for(i=0;i<n;i++){
		dup[i]=(struct task *)malloc(sizeof(struct task));
		dup[i]->home=t[i]->home;
		dup[i]->done=t[i]->done;
		dup[i]->id=t[i]->id;
		dup[i]->np=t[i]->np;
		for(j=0;j<t[i]->np;j++)
			dup[i]->pre[j]=t[i]->pre[j];
	}
	return dup;
}
struct home homes[3];
void make(struct task *t[],struct bstnode *root,int i,int n){
	int idx,idx2;
	int j;
	root->visit=0;
	struct task **dup=dup1(t,n);
	root->id=dup[i]->home;
	for(idx=0;idx<homes[dup[i]->home-1].nt;idx++)    //doing all the tasks that has no prereq
		if(dup[homes[dup[i]->home-1].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home-1].tasks[idx]-1]->done==0){
			dup[homes[dup[i]->home-1].tasks[idx]-1]->done=1;
			for(idx2=0;idx2<n;idx2++)
					for(j=0;dup[idx2]->pre[j]!=0;j++)
						if(dup[idx2]->pre[j]==dup[homes[dup[i]->home-1].tasks[idx]-1]->id){
							dup[idx2]->pre[j]=-1;
							dup[idx2]->np--;
						}
		}
	for(idx=0;idx<homes[dup[i]->home%3].nt;idx++)    //checking nei
		if(dup[homes[dup[i]->home%3].tasks[idx]-1]->np==0 && dup[homes[dup[i]->home%3].tasks[idx]-1]->done==0){
			root->left=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->left->left=NULL;
			root->left->right=NULL;
			make(dup,root->left,dup[homes[dup[i]->home%3].tasks[idx]-1]->id-1,n);
		}
	int home;
	if(dup[i]->home==1)
		home=2;
	else
		home=dup[i]->home-2;
	for(idx=0;idx<homes[home].nt;idx++)		//checking nei
		if(dup[homes[home].tasks[idx]-1]->np==0 && dup[homes[home].tasks[idx]-1]->done==0){
			root->right=(struct bstnode *)malloc(sizeof(struct bstnode));
			root->right->right=NULL;
			root->right->left=NULL;
			make(dup,root->right,dup[homes[home].tasks[idx]-1]->id-1,n);
		}

}
void chg(struct bstnode a){
	if(a.id==3)
		printf("%d",a.id);
	else{
		a.id=3;
		chg(a);
	}
}
int cal(struct bstnode *root,int cost){
	if(root==NULL)
		return cost;
	int left=0,right=0;
	if(root->left!=NULL)
		left=cal(root->left,cost+1);
	if(root->right!=NULL)
		right=cal(root->right,cost+2);
	if(left==0 && right==0)
		return cost;
	if(left==0 && right!=0)
		return right;
	if(right==0 && left!=0)
		return left;
	return (left>right)?right:left;
}
void print(struct bstnode *root, int i){
	if(root==NULL)
		return;
	/*if(root->visit)
		return ;
	root->visit=1;*/
	print(root->left,1);
	if(i==1)
		printf("left:");
	else if(i==0)
		printf("root:");
	else if(i==2)
		printf("right:");
	printf("%d ",root->id);
	print(root->right,2);
}
/*long long a[10000000];
long long b[10000000];
long long p[10000000];
long long primes[700000];*/
int a[10000000];
int l[1000000];
void prin(int num,int n){
	int i;
	if(num==0 || num==1 || num==2){
		printf("%d ",num);
		return ;
	}
	for(i=n-1;i>=0 && a[i]>num;i--);
	printf("%d ",a[i]);
	prin(n-a[i],n);
}
main(){
	char s[20];
	int i,j,idx=0;
	getword(s,20);
	int num=atoi(s);
	getword(s,20);
	int k=atoi(s);
	for(i=0;i<k;i++)
		a[i]=0;
	if(num==1){
		printf("1\n1");
		return 0;
	}
	int sum=1;
	a[i++]=1;
	for(;sum<num;i++){
		a[i]=sum;
		sum-=a[i-k];
		sum+=a[i];
	}
	j=i-1;
	while(num>2){
		l[idx++]=a[j];
		num-=a[j];
		for(j=i-1;j>=0 && a[j]>num;j--);
	}
	l[idx++]=num;
	printf("%d\n",idx);
	for(j=0;j<idx;j++)
		printf("%d ",l[j]);
	return 0;
}

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

int main(void){
  int fib[45]={0},stock[45]={0};
  int s,k,i,n,sum=0,num=0;
  scanf("%d %d",&s,&k);
  for(i=0;i==0||fib[i-1]<=s;i++){
    if(i<=1) fib[i]=1;
    else if(i<=k) fib[i]=sum;
    else{
      sum-=fib[i-k-1];
      fib[i]=sum;
    }
    //printf("%d %d\n",i,fib[i]);
    sum+=fib[i];
    //printf("sum:%d\n",sum);
  }
  //printf("i:%d\n",i);
  n=i-2;
  if(fib[i-2]==s) n--;
  //printf("n:%d %d\n",n,fib[n]);
  for(i=n;i>=0;i--){
    if(fib[i]<=s){
      stock[num++]=fib[i];
      s-=fib[i];
      if(s==0) break;
    }
  }
  printf("%d\n",num);
  for(i=num-1;i>=0;i--){
    printf("%d",stock[i]);
    putchar((i>0)?' ':'\n');
  }
  return 0;
}

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

int main(void){
  int fib[45],stock[45];
  int s,k,i,n,sum=0,num=0;
  scanf("%d %d",&s,&k);
  for(i=0;fib[i-1]<=s;i++){
    if(i<=1) fib[i]=1;
    else if(i<k&&k!=2) fib[i]=sum;
    else{
      sum-=fib[i-1-k];
      fib[i]=sum;
    }
    //printf("%d %d\n",i,fib[i]);
    sum+=fib[i];
  }
  n=i-2;
  if(fib[i-2]==s) n--;
  //printf("n:%d %d\n",n,fib[n]);
  for(i=n;i>=0;i--){
    if(fib[i]<=s){
      stock[num++]=fib[i];
      s-=fib[i];
      if(s==0) break;
    }
  }
  printf("%d\n",num);
  for(i=num-1;i>=0;i--){
    printf("%d",stock[i]);
    putchar((i>0)?' ':'\n');
  }
  //printf("%d %d\n",n,fib[(i-1)%3]);
  return 0;
}

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

int main(void){
  int fib[45]={0},stock[45]={0};
  int s,k,i,n,sum=0,num=0;
  scanf("%d %d",&s,&k);
  for(i=0;i==0||fib[i-1]<=s;i++){
    if(i<=1) fib[i]=1;
    else if(i<=k) fib[i]=sum;
    else{
      sum-=fib[i-k-1];
      fib[i]=sum;
    }
    //printf("%d %d\n",i,fib[i]);
    sum+=fib[i];
    //printf("sum:%d\n",sum);
  }
  //printf("i:%d\n",i);
  n=i-2;
  if(fib[i-2]==s) n--;
  //printf("n:%d %d\n",n,fib[n]);
  for(i=n;i>=0;i--){
    if(fib[i]<=s){
      stock[num++]=fib[i];
      s-=fib[i];
      if(s==0) break;
    }
  }
  if(num==1) fib[num++]=0;
  printf("%d\n",num);
  for(i=num-1;i>=0;i--){
    printf("%d",stock[i]);
    putchar((i>0)?' ':'\n');
  }
  return 0;
}

 #include <stdio.h>

 long kf[1000];
 long ch[1000];

 int main(){
     long s, k;
     int m=0;
     int i, j;
     int n;
     int alone=1;
     scanf ("%ld%ld", &s, &k);
     i=k-1;
     kf[i]=1;
     while (kf[i]<=s){
         i++;
         for (j=i-1; j>=i-k; j--)
            kf[i]+=kf[j];
     }
     while (s>0 || alone){
         while (kf[i]>s) i--;
         while (kf[i]==s && alone) i--;
         while (kf[i]==ch[m-1]) i--;
         s-=kf[i];
         alone=0;
         ch[m]=kf[i];
         m++;
         i--;
     }
     printf ("%d\n", m);
     for (i=0; i<m; i++)
        printf ("%ld ", ch[i]);
     printf ("\n");
     return 0;
 }

 #include <stdio.h>

 long kf[1000];
 long ch[1000];

 int main(){
     long s, k;
     int m=1;
     long tmp;
     int i, j;
     int n;
     int alone=0;
     scanf ("%ld%ld", &s, &k);
     kf[1]=1;
     i=1;
     while (kf[i]<=s){
         i++;
         tmp=i-k;
         if (tmp<0) tmp=0;
         for (j=i-1; j>=tmp; j--)
            kf[i]+=kf[j];
     }
     while (s>0){
         while (kf[i]>s) i--;
         if (kf[i]==s) alone++;
         s=s-kf[i];
         ch[m]=kf[i];
         m++;
         i--;
     }
     if (alone){
         ch[m]=0;
         m++;
     }
     printf ("%d\n", m);
     for (i=1; i<=m; i++)
        printf ("%ld ", ch[i]);
     printf ("\n");
     return 0;
 }

 #include <stdio.h>

 long kf[1000];
 long ch[1000];

 int main(){
     long s, k;
     int m=0;
     int i, j;
     int n;
     int alone=1;
     scanf ("%ld%ld", &s, &k);
     i=k-1;
     kf[i]=1;
     while (kf[i]<=s){
         i++;
         for (j=i-1; j>=i-k; j--)
            kf[i]+=kf[j];
     }

     while (s>0){
         while (kf[i]>s) i--;
         if (kf[i]==s && alone) i--;
         s-=kf[i];
         alone=0;
         ch[m]=kf[i];
         m++;
         i--;
     }
     printf ("%d\n", m);
     for (i=0; i<m; i++)
        printf ("%ld ", ch[i]);
     printf ("\n");
     return 0;
 }

 #include <stdio.h>

 long kf[1000];
 long ch[1000];

 int main(){
     long s, k;
     int m=0;
     int i, j;
     int n;
     int alone=1;
     scanf ("%ld%ld", &s, &k);
     i=k-1;
     kf[i]=1;
     while (kf[i]<=s){
         i++;
         for (j=i-1; j>=i-k; j--)
            kf[i]+=kf[j];
     }
     while (s>0){
         while (kf[i]>s) i--;
         while (kf[i]==s && alone) i--;
         while (kf[i]==ch[m-1]) i--;
         s-=kf[i];
         alone=0;
         ch[m]=kf[i];
         m++;
         i--;
     }
     printf ("%d\n", m);
     for (i=0; i<m; i++)
        printf ("%ld ", ch[i]);
     printf ("\n");
     return 0;
 }

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

int S, K, i;
long long int F[100];
int Counter;
int Ans[100];
int k;

int main(){
    while(~scanf("%d%d", &S, &K)){
        F[0] = 0;
        F[1] = 1;
        F[2] = 1;

        k=K;
        if (k>30) k = 30;

        for (i=3; F[i-1]<(1<<(k-1)); i++) F[i] = 1<<(i-2);

        for ( ; F[i-1]<S; i++) F[i] = 2*F[i-1] - F[i-k-1];
        i--;
        if (F[i]==S) i--;
        Counter = 0;
        while(i){
            if (S==0) break;
            if (F[i]>S){
                i--;
                continue;
            }
            Ans[Counter] = F[i];
            Counter++;
            S -= F[i];
            i--;
        }
        printf("%d\n", Counter);
        printf("%d", Ans[0]);
        for (i=1; i<Counter; i++) printf(" %d", Ans[i]);
        putchar(10);
    }

    return 0;
}

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

int S, K, i;
long long int F[1000];
int Counter;
int Ans[1000];

int main(){
    while(~scanf("%d%d", &S, &K)){
        for (i=0; i<K; i++) F[i] = 0;
        F[K] = 1;
        F[K+1] = 1;
        for (i=K+2; F[i-1]<S; i++) F[i] = 2*F[i-1] - F[i-K-1];
        i--;

        Counter = 0;
        while(i){
            if (S==0) break;
            if (F[i]>S){
                i--;
                continue;
            }
            Ans[Counter] = F[i];
            Counter++;
            S -= F[i];
            i--;
        }
        printf("%d\n", Counter);
        printf("%d", Ans[0]);
        for (i=1; i<Counter; i++) printf(" %d", Ans[i]);
        putchar(10);
    }

    return 0;
}

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

int S, K, i;
long long int F[1000];
int Counter;
int Ans[1000];

int main(){
    while(~scanf("%d%d", &S, &K)){
        for (i=0; i<K; i++) F[i] = 0;
        F[K] = 1;
        F[K+1] = 1;
        for (i=K+2; F[i-1]<S; i++) F[i] = 2*F[i-1] - F[i-K-1];
        i--;
        i--;
        Counter = 0;
        while(i){
            if (S==0) break;
            if (F[i]>S){
                i--;
                continue;
            }
            Ans[Counter] = F[i];
            Counter++;
            S -= F[i];
            i--;
        }
        printf("%d\n", Counter);
        printf("%d", Ans[0]);
        for (i=1; i<Counter; i++) printf(" %d", Ans[i]);
        putchar(10);
    }

    return 0;
}

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

int S, K, i;
long long int F[100];
int Counter;
int Ans[100];
int k;

int main(){
    while(~scanf("%d%d", &S, &K)){
        F[0] = 0;
        F[1] = 1;
        F[2] = 1;

        k=K;
        if (k>60) k = 60;

        for (i=3; F[i-1]<(1<<(k-1)); i++) F[i] = 1<<(i-2);

        for ( ; F[i-1]<S; i++) F[i] = 2*F[i-1] - F[i-k-1];
        i--;
        i--;
        Counter = 0;
        while(i){
            if (S==0) break;
            if (F[i]>S){
                i--;
                continue;
            }
            Ans[Counter] = F[i];
            Counter++;
            S -= F[i];
            i--;
        }
        printf("%d\n", Counter);
        printf("%d", Ans[0]);
        for (i=1; i<Counter; i++) printf(" %d", Ans[i]);
        putchar(10);
    }

    return 0;
}

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

int S, K, i;
long long int F[100];
int Counter;
int Ans[100];

int main(){
    while(~scanf("%d%d", &S, &K)){
        F[0] = 0;
        F[1] = 1;
        F[2] = 1;

        for (i=3; F[i-1]<(1<<(K-1)); i++) F[i] = 1<<(i-2);

        for ( ; F[i-1]<S; i++) F[i] = 2*F[i-1] - F[i-K-1];
        i--;
        i--;
        Counter = 0;
        while(i){
            if (S==0) break;
            if (F[i]>S){
                i--;
                continue;
            }
            Ans[Counter] = F[i];
            Counter++;
            S -= F[i];
            i--;
        }
        printf("%d\n", Counter);
        printf("%d", Ans[0]);
        for (i=1; i<Counter; i++) printf(" %d", Ans[i]);
        putchar(10);
    }

    return 0;
}

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

int s,k,t,x;
int memo[9999],ans,c[9999],p;

int make_k_bonacci(int k){
    int i,j;
    memo[k] = 1;
    for(i=k+1;;i++){
        for(j=1;j<=k;j++){
            memo[i] += memo[i-j];
            if(memo[i]<0) return i;
        }
    }
}

main(){
    scanf("%d%d",&s,&k);
    t=k;
    if(k>=32){
        x = __builtin_popcount(s);
        if(x==1){
            printf("2\n0 %d\n",s);
            return 0;
        }
        printf("%d\n",x);
        while(s){
            t=s&-s;
            printf("%d ",t);
            s^=t;
        }
        puts("");
        return 0;
    }
    int z = make_k_bonacci(k);
    t=s;
    while(z--&&s){
        if(s>=memo[z]&&memo[z]!=t){
            ans++;
            c[p++]=memo[z];
            s-=memo[z];
        }
    }
    printf("%d\n",ans);
    while(p--)printf("%d ",c[p]);
    puts("");
    return 0;
}

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

int s,k,t,x;

main(){
    scanf("%d%d",&s,&k);
    t=k;
    x = __builtin_popcount(s);
    if(x==1){
        printf("2\n0 %d\n",s);
        return 0;
    }
    printf("%d\n",x);
    while(s){
        t=s&-s;
        printf("%d ",t);
        s^=t;
    }
    puts("");
    return 0;
}