#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=1048576;
int sl;
const double dd=1/1048576;
double epsilon=1e-9;
int n,k;
//comp pr[1048576];
//comp w;
double PI;
int a[1005];
bool d[5000005];
bool p[5000005];
//comp t[mm];
//comp e[mm];
//comp o[mm];

vector<comp> t;
int reverse(int i,int m)
{
	int j=0;
	int l1=1;
	int l2=m>>1;
	while(l1<l2)
	{
		if((i&l1)>0) j+=l2;
		if((i&l2)>0) j+=l1;
		l1=l1<<1;
		l2=l2>>1;
	}
	if(l1==l2)
	{
		if((i&l1)) j+=l1;
	}
	return j;
}
inline vector<comp > FFT(vector<comp > &p,int m,bool nin)
{
	vector<comp > ef,of,e,o,t;
	if(m==1) return p;
	for(int i=0;i<m;i++)
	{
		int j=reverse(i,m);
		if(i<j) swap(p[i],p[j]);
	}
	comp x,y;
	comp w;
	comp d;
	d.x=1.0;
	d.y=0.0;
	for(int l=2;l<=m;l=l<<1)
	{
		w=polarcomp(1.0,2.0*PI/double(l));
		if(!nin) w=compinverse(w);
		for(int j=0;j<m;j=j+l)
		{
			d.x=1.0;
			d.y=0.0;
			//cout<<j<<" "<<l<<" "<<m<<endl;
			for(int i=j;i<j+(l>>1);i++)
			{
				x=p[i];
				y=p[i+(l>>1)]*d;
				p[i]=x+y;
				p[i+(l>>1)]=x-y;
				d=d*w;
			}
		}
	}
	return p;
}
void Multiply(bool*x,bool*y)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if(x[i] || y[i]) m=i;
	}
	m=m+10;
	double t=m;
	t=log(t)/log(2.0);
	m=t;
	m=pow(2,m+1);
	m=(m<<1);
	if(m>=2000000)
	{
		while(true)
		{
			m++;
		}
	}
	vector<comp > pr,u,v,r;
	pr.resize(m);
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(x[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	u.clear();
	u=FFT(pr,m,true);
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(y[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	v.clear();
	v=FFT(pr,m,true);
	for(int i=0;i<m;i++) pr[i]=u[i]*v[i];
	r.clear();
	r=FFT(pr,m,false);
	for(int i=0;i<m;i++)
	{
		if(r[i].x>epsilon) x[i]=true;
		else x[i]=false;
	}
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		l=(l<<1);
	}
}
int main()
{
	t.resize(mm);
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve();
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <complex>
#include <bits\stdc++.h>
const int mm=32768;
int sl;
const double dd=1/32768.0;
using namespace std;
double epsilon=1e-9;
int n,k;
//complex<double> pr[1048576];
complex<double> w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//complex<double> t[mm];
//complex<double> e[mm];
//complex<double> o[mm];

/*vector<complex<double> > t;
vector<complex<double> > ef;
vector<complex<double> > of;
vector<complex<double> > e;
vector<complex<double> > o;*/
inline vector<complex<double> > FFT(vector<complex<double> > p,int m,complex<double> r)
{
	vector<complex<double> > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	//e.clear();
	//o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	//ef.clear();
	//of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	complex<double>x(1.0,0.0);
	//t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	//sl+=5*m;
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=mm;
	vector<complex<double> > pr,u,v,r;
	pr.resize(mm);
	double t=dd;
	//cout<<t<<endl;
	for(int i=0;i<mm;i++)
	{
		if(x[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	u.clear();
	//sl=0;
	//cout<<"?"<<endl;
	u=FFT(pr,mm,w);
	//cout<<sl<<endl;
	for(int i=0;i<mm;i++)
	{
		if(y[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	v.clear();
	v=FFT(pr,mm,w);
	for(int i=0;i<mm;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	complex<double> inw;
	inw=w;
	inw=1.0/w;
	//cout<<inw<<endl;
	r=FFT(pr,mm,inw);
	for(int i=0;i<mm;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].real()>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	w=polar(1.0,2.0*PI*dd);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=1048576;
int sl;
const double dd=1/1048576;
double epsilon=1e-9;
int n,k;
//comp pr[1048576];
comp w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//comp t[mm];
//comp e[mm];
//comp o[mm];

/*vector<comp > t;
vector<comp > ef;
vector<comp > of;
vector<comp > e;
vector<comp > o;*/
inline vector<comp > FFT(vector<comp > p,int m,comp r)
{
	vector<comp > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	//e.clear();
	//o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	//ef.clear();
	//of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	comp x;
	x.x=1.0;
	x.y=0.0;
	//t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	//sl+=5*m;
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if(x[i] || y[i]) m=i;
	}
	m=log(m);
	m=pow(2,m+1);
	//m=m+2;
	//cout<<m<<endl;
	m=(m<<1);
	double t;
	t=m;
	t=1.0/t;
	w=polarcomp(1.0,2.0*PI*t);
	vector<comp > pr,u,v,r;
	pr.resize(m);
	//cout<<t<<endl;
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(x[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	u.clear();
	//sl=0;
	//cout<<"?"<<endl;
	u=FFT(pr,m,w);
	//cout<<sl<<endl;
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(y[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	v.clear();
	v=FFT(pr,m,w);
	for(int i=0;i<m;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	comp inw;
	inw=w;
	inw=compinverse(w);
	//cout<<inw<<endl;
	r=FFT(pr,m,inw);
	for(int i=0;i<m;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].x>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	//w=polarcomp(1.0,2.0*PI*dd);
	//cout<<w.x<<" "<<w.y<<endl;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <complex>
const int mm=1048576;
const double dd=1/1048576.0;
using namespace std;
double epsilon=1e-9;
int n,k;
//complex<double> pr[1048576];
complex<double> w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//complex<double> t[mm];
//complex<double> e[mm];
//complex<double> o[mm];

/*vector<complex<double> > t;
vector<complex<double> > ef;
vector<complex<double> > of;
vector<complex<double> > e;
vector<complex<double> > o;*/
vector<complex<double> > FFT(vector<complex<double> > p,int m,complex<double> r)
{
	vector<complex<double> > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	e.clear();
	o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	ef.clear();
	of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	complex<double>x(1.0,0.0);
	t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=mm;
	vector<complex<double> > pr,u,v,r;
	pr.resize(mm);
	double t=dd;
	//cout<<t<<endl;
	for(int i=0;i<mm;i++)
	{
		if(x[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	u.clear();
	u=FFT(pr,mm,w);
	//cout<<"?"<<endl;
	for(int i=0;i<mm;i++)
	{
		if(y[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	v.clear();
	v=FFT(pr,mm,w);
	for(int i=0;i<mm;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	complex<double> inw;
	inw=w;
	inw=1.0/w;
	//cout<<inw<<endl;
	r=FFT(pr,mm,inw);
	for(int i=0;i<mm;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].real()>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	w=polar(1.0,2.0*PI*dd);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=2097152;
int sl;
const double dd=1/2097152;
double epsilon=1e-5;
int n,k;
double PI;
int a[1005];
bool d[5000005];
bool p[5000005];
comp pr[5000005];
comp u[5000005];
//comp v[5000005];
int reverse(int i,int m)
{
	int j=0;
	int l1=1;
	int l2=m>>1;
	while(l1<l2)
	{
		if((i&l1)>0) j+=l2;
		if((i&l2)>0) j+=l1;
		l1=l1<<1;
		l2=l2>>1;
	}
	if(l1==l2)
	{
		if((i&l1)) j+=l1;
	}
	return j;
}
inline void FFT(int m,bool nin)
{
	for(int i=0;i<m;i++)
	{
		int j=reverse(i,m);
		if(i<j) swap(pr[i],pr[j]);
	}
	comp x,y;
	comp w;
	comp d;
	d.x=1.0;
	d.y=0.0;
	for(int l=2;l<=m;l=l<<1)
	{
		w=polarcomp(1.0,2.0*PI/double(l));
		if(!nin) w=compinverse(w);
		for(int j=0;j<m;j=j+l)
		{
			d.x=1.0;
			d.y=0.0;
			for(int i=j;i<j+(l>>1);i++)
			{
				x=pr[i];
				y=pr[i+(l>>1)]*d;
				pr[i]=x+y;
				pr[i+(l>>1)]=x-y;
				d=d*w;
			}
		}
	}
}
void Multiply(bool nec)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if((nec && d[i]) || p[i]) m=i;
	}
	m=m+10;
	double t=m;
	t=log(t)/log(2.0);
	m=t;
	m=pow(2,m+1);
	m=(m<<1);
	//m=(m<<1);
	//cout<<m<<endl;
	/*if(m>=2000000)
	{
		while(true)
		{
			m++;
		}
	}*/
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(nec)
		{
			if(d[i]) pr[i].x=1.0;
			else pr[i].x=0.0;
		}
		else
		{
			if(p[i]) pr[i].x=1.0;
			else pr[i].x=0.0;
		}
	}
	FFT(m,true);
	for(int i=0;i<m;i++)
	{
		u[i].x=pr[i].x;
		u[i].y=pr[i].y;
		pr[i].y=0.0;
		if(p[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	FFT(m,true);
	for(int i=0;i<m;i++) pr[i]=pr[i]*u[i];
	FFT(m,false);
	t=1/double(m);
	//t=1;
	for(int i=0;i<m;i++)
	{
		if(pr[i].x*t>epsilon)
		{
			if(nec) d[i]=true;
			else p[i]=true;
		}
		else
		{
			if(nec) d[i]=false;
			else p[i]=false;
		}
	}
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(true);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(false);
		l=(l<<1);
		/*cout<<l<<endl;
		for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		cout<<endl<<endl<<endl;

		cout<<(l>>1)<<endl;
		for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
		cout<<endl<<endl<<endl;*/
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve();
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=1048576;
int sl;
const double dd=1/1048576;
double epsilon=1e-9;
int n,k;
//comp pr[1048576];
comp w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//comp t[mm];
//comp e[mm];
//comp o[mm];

/*vector<comp > t;
vector<comp > ef;
vector<comp > of;
vector<comp > e;
vector<comp > o;*/
inline vector<comp > FFT(vector<comp > p,int m,comp r)
{
	vector<comp > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	//e.clear();
	//o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	//ef.clear();
	//of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	comp x;
	x.x=1.0;
	x.y=0.0;
	//t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	//sl+=5*m;
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if(x[i] || y[i]) m=i;
	}
	m=m+2;
	//cout<<m<<endl;
	m=log(m);
	m=pow(2,m+1);
	//m=m+2;
	//cout<<m<<endl;
	m=(m<<1);
	double t;
	t=m;
	t=1.0/t;
	w=polarcomp(1.0,2.0*PI*t);
	vector<comp > pr,u,v,r;
	pr.resize(m);
	//cout<<t<<endl;
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(x[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	u.clear();
	//sl=0;
	//cout<<"?"<<endl;
	u=FFT(pr,m,w);
	//cout<<sl<<endl;
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(y[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	v.clear();
	v=FFT(pr,m,w);
	for(int i=0;i<m;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	comp inw;
	inw=w;
	inw=compinverse(w);
	//cout<<inw<<endl;
	r=FFT(pr,m,inw);
	for(int i=0;i<m;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].x>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	//w=polarcomp(1.0,2.0*PI*dd);
	//cout<<w.x<<" "<<w.y<<endl;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=2097152;
int sl;
const double dd=1/2097152;
double epsilon=1e-9;
int n,k;
double PI;
int a[1005];
bool d[5000005];
bool p[5000005];
comp pr[5000005];
comp u[5000005];
//comp v[5000005];
int reverse(int i,int m)
{
	int j=0;
	int l1=1;
	int l2=m>>1;
	while(l1<l2)
	{
		if((i&l1)>0) j+=l2;
		if((i&l2)>0) j+=l1;
		l1=l1<<1;
		l2=l2>>1;
	}
	if(l1==l2)
	{
		if((i&l1)) j+=l1;
	}
	return j;
}
inline void FFT(int m,bool nin)
{
	for(int i=0;i<m;i++)
	{
		int j=reverse(i,m);
		if(i<j) swap(pr[i],pr[j]);
	}
	comp x,y;
	comp w;
	comp d;
	d.x=1.0;
	d.y=0.0;
	for(int l=2;l<=m;l=l<<1)
	{
		w=polarcomp(1.0,2.0*PI/double(l));
		if(!nin) w=compinverse(w);
		for(int j=0;j<m;j=j+l)
		{
			d.x=1.0;
			d.y=0.0;
			for(int i=j;i<j+(l>>1);i++)
			{
				x=pr[i];
				y=pr[i+(l>>1)]*d;
				pr[i]=x+y;
				pr[i+(l>>1)]=x-y;
				d=d*w;
			}
		}
	}
}
void Multiply(bool nec)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if((nec && d[i]) || p[i]) m=i;
	}
	m=m+10;
	double t=m;
	t=log(t)/log(2.0);
	m=t;
	m=pow(2,m+1);
	m=(m<<1);
	//m=(m<<1);
	//cout<<m<<endl;
	/*if(m>=2000000)
	{
		while(true)
		{
			m++;
		}
	}*/
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(nec)
		{
			if(d[i]) pr[i].x=1.0;
			else pr[i].x=0.0;
		}
		else
		{
			if(p[i]) pr[i].x=1.0;
			else pr[i].x=0.0;
		}
	}
	FFT(m,true);
	for(int i=0;i<m;i++)
	{
		u[i].x=pr[i].x;
		u[i].y=pr[i].y;
		pr[i].y=0.0;
		if(p[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	FFT(m,true);
	for(int i=0;i<m;i++) pr[i]=pr[i]*u[i];
	FFT(m,false);
	t=1/double(m);
	//t=1;
	for(int i=0;i<m;i++)
	{
		if(pr[i].x*t>epsilon)
		{
			if(nec) d[i]=true;
			else p[i]=true;
		}
		else
		{
			if(nec) d[i]=false;
			else p[i]=false;
		}
	}
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(true);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(false);
		l=(l<<1);
		/*cout<<l<<endl;
		for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		cout<<endl<<endl<<endl;

		cout<<(l>>1)<<endl;
		for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
		cout<<endl<<endl<<endl;*/
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve();
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <complex>
const int mm=1024;
const double dd=1/1024.0;
using namespace std;
double epsilon=1e-9;
int n,k;
//complex<double> pr[1048576];
complex<double> w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//complex<double> t[mm];
//complex<double> e[mm];
//complex<double> o[mm];

/*vector<complex<double> > t;
vector<complex<double> > ef;
vector<complex<double> > of;
vector<complex<double> > e;
vector<complex<double> > o;*/
vector<complex<double> > FFT(vector<complex<double> > p,int m,complex<double> r)
{
	vector<complex<double> > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	e.clear();
	o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	ef.clear();
	of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	complex<double>x(1.0,0.0);
	t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=mm;
	vector<complex<double> > pr,u,v,r;
	pr.resize(mm);
	double t=dd;
	//cout<<t<<endl;
	for(int i=0;i<mm;i++)
	{
		if(x[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	u.clear();
	u=FFT(pr,mm,w);
	//cout<<"?"<<endl;
	for(int i=0;i<mm;i++)
	{
		if(y[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	v.clear();
	v=FFT(pr,mm,w);
	for(int i=0;i<mm;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	complex<double> inw;
	inw=w;
	inw=1.0/w;
	//cout<<inw<<endl;
	r=FFT(pr,mm,inw);
	for(int i=0;i<mm;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].real()>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	w=polar(1.0,2.0*PI*dd);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=4194304;
int sl;
const double dd=1/4194304;
double epsilon=1e-9;
int n,k;
//comp pr[1048576];
//comp w;
double PI;
int a[1005];
bool d[5000005];
bool p[5000005];
//comp t[mm];
//comp e[mm];
//comp o[mm];

vector<comp> t;
int reverse(int i,int m)
{
	int j=0;
	int l1=1;
	int l2=m>>1;
	while(l1<l2)
	{
		if((i&l1)>0) j+=l2;
		if((i&l2)>0) j+=l1;
		l1=l1<<1;
		l2=l2>>1;
	}
	if(l1==l2)
	{
		if((i&l1)) j+=l1;
	}
	return j;
}
inline vector<comp > FFT(vector<comp > &p,int m,bool nin)
{
	vector<comp > ef,of,e,o,t;
	if(m==1) return p;
	for(int i=0;i<m;i++)
	{
		int j=reverse(i,m);
		if(i<j) swap(p[i],p[j]);
	}
	comp x,y;
	comp w;
	comp d;
	d.x=1.0;
	d.y=0.0;
	for(int l=2;l<=m;l=l<<1)
	{
		w=polarcomp(1.0,2.0*PI/double(l));
		if(!nin) w=compinverse(w);
		for(int j=0;j<m;j=j+l)
		{
			d.x=1.0;
			d.y=0.0;
			//cout<<j<<" "<<l<<" "<<m<<endl;
			for(int i=j;i<j+(l>>1);i++)
			{
				x=p[i];
				y=p[i+(l>>1)]*d;
				p[i]=x+y;
				p[i+(l>>1)]=x-y;
				d=d*w;
			}
		}
	}
	return p;
}
void Multiply(bool*x,bool*y)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if(x[i] || y[i]) m=i;
	}
	m=m+10;
	double t=m;
	t=log(t)/log(2.0);
	m=t;
	m=pow(2,m+1);
	m=(m<<1);
	t=m;
	t=1.0/t;
	vector<comp > pr,u,v,r;
	pr.resize(m);
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(x[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	u.clear();
	u=FFT(pr,m,true);
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(y[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	v.clear();
	v=FFT(pr,m,true);
	for(int i=0;i<m;i++) pr[i]=u[i]*v[i];
	r.clear();
	r=FFT(pr,m,false);
	for(int i=0;i<m;i++)
	{
		if(r[i].x>epsilon) x[i]=true;
		else x[i]=false;
	}
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		l=(l<<1);
	}
}
int main()
{
	t.resize(mm);
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve();
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=1048576;
int sl;
const double dd=1/1048576;
double epsilon=1e-9;
int n,k;
//comp pr[1048576];
comp w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//comp t[mm];
//comp e[mm];
//comp o[mm];

/*vector<comp > t;
vector<comp > ef;
vector<comp > of;
vector<comp > e;
vector<comp > o;*/
inline vector<comp > FFT(vector<comp > p,int m,comp r)
{
	vector<comp > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	//e.clear();
	//o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	//ef.clear();
	//of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	comp x;
	x.x=1.0;
	x.y=0.0;
	//t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	//sl+=5*m;
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if(x[i] || y[i]) m=i;
	}
	//cout<<"  "<<m<<endl;
	m=m+10;
	double t=m;
	//cout<<m<<endl;
	t=log(t)/log(2.0);
	//cout<<t<<endl;
	m=t;
	//cout<<m<<endl;
	m=pow(2,m+1);
	//m=m+2;
	//cout<<m<<endl;
	m=(m<<1);
	//cout<<m<<endl;
	t=m;
	t=1.0/t;
	w=polarcomp(1.0,2.0*PI*t);
	vector<comp > pr,u,v,r;
	pr.resize(m);
	//cout<<t<<endl;
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(x[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	u.clear();
	//sl=0;
	//cout<<"?"<<endl;
	u=FFT(pr,m,w);
	//cout<<sl<<endl;
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(y[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	v.clear();
	v=FFT(pr,m,w);
	for(int i=0;i<m;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	comp inw;
	inw=w;
	inw=compinverse(w);
	//cout<<inw<<endl;
	r=FFT(pr,m,inw);
	for(int i=0;i<m;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].x>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	//w=polarcomp(1.0,2.0*PI*dd);
	//cout<<w.x<<" "<<w.y<<endl;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <complex>
#include <bits\stdc++.h>
const int mm=16384;
int sl;
const double dd=1/16384.0;
using namespace std;
double epsilon=1e-9;
int n,k;
//complex<double> pr[1048576];
complex<double> w;
double PI;
int a[1005];
bool d[2000005];
bool p[2000005];
//complex<double> t[mm];
//complex<double> e[mm];
//complex<double> o[mm];

/*vector<complex<double> > t;
vector<complex<double> > ef;
vector<complex<double> > of;
vector<complex<double> > e;
vector<complex<double> > o;*/
inline vector<complex<double> > FFT(vector<complex<double> > p,int m,complex<double> r)
{
	vector<complex<double> > ef,of,e,o,t;
	//cout<<m<<" = "<<p.size()<<endl;
	if(m==1) return p;
	//e.clear();
	//o.clear();
	for(int i=0;i<m/2;i++)
	{
		e.push_back(p[i*2]);
		o.push_back(p[i*2+1]);
	}
	//cout<<e.size()<<" "<<o.size()<<endl;
	//cout<<"?"<<endl;
	//ef.clear();
	//of.clear();
	ef=FFT(e,m/2,r*r);
	//cout<<"? "<<ef.size()<<endl;
	of=FFT(o,m/2,r*r);
	complex<double>x(1.0,0.0);
	//t.clear();
	t.resize(m);
	for(int i=0;i<m/2;i++)
	{
		t[i]=ef[i]+x*of[i];
		t[i+m/2]=ef[i]-x*of[i];
		//cout<<r<<" "<<x<<" "<<x*r<<endl;
		x=x*r;
	}
	//sl+=5*m;
	return t;
}
void Multiply(bool*x,bool*y)
{
	int m=mm;
	vector<complex<double> > pr,u,v,r;
	pr.resize(mm);
	double t=dd;
	//cout<<t<<endl;
	for(int i=0;i<mm;i++)
	{
		if(x[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	u.clear();
	//sl=0;
	//cout<<"?"<<endl;
	u=FFT(pr,mm,w);
	//cout<<sl<<endl;
	for(int i=0;i<mm;i++)
	{
		if(y[i]) pr[i]=1.0;
		else pr[i]=0.0;
	}
	v.clear();
	v=FFT(pr,mm,w);
	for(int i=0;i<mm;i++) pr[i]=u[i]*v[i];
	/*for(int i=0;i<mm;i++) cout<<u[i]<<" ";
	cout<<endl;
	for(int i=0;i<mm;i++) cout<<v[i]<<" ";
	cout<<endl;*/
	r.clear();
	complex<double> inw;
	inw=w;
	inw=1.0/w;
	//cout<<inw<<endl;
	r=FFT(pr,mm,inw);
	for(int i=0;i<mm;i++)
	{
		//cout<<r[i]<<" ";
		if(r[i].real()>epsilon) x[i]=true;
		else x[i]=false;
	}
	//cout<<endl<<endl<<endl;
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	//p[0]=true;
	//d[0]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(d,p);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(p,p);
		//cout<<l<<endl;
		//for(int i=1;i<=1000000;i++) if(p[i]) printf("%d ",i);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	w=polar(1.0,2.0*PI*dd);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve(); //Pronaci sve polinome koje treba pomnoziti
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits\stdc++.h>

using namespace std;
struct comp
{
	double x,y;
};
inline comp operator *(comp a,comp b)
{
	comp z;
	z.x=a.x*b.x-a.y*b.y;
	z.y=a.x*b.y+a.y*b.x;
	return z;
}
inline comp operator +(comp a,comp b)
{
	comp z;
	z.x=a.x+b.x;
	z.y=a.y+b.y;
	return z;
}
inline comp operator -(comp a,comp b)
{
	comp z;
	z.x=a.x-b.x;
	z.y=a.y-b.y;
	return z;
}
inline comp polarcomp(double r,double ang)
{
	comp z;
	//cout<<r<<" "<<ang<<" "<<cos(ang)<<" "<<sin(ang)<<endl;
	z.x=r*cos(ang);
	z.y=r*sin(ang);
	return z;
}
inline comp compinverse(comp w)
{
	comp z;
	z.x=(w.x)/(w.x*w.x+w.y*w.y);
	z.y=(-w.y)/(w.x*w.x+w.y*w.y);
	return z;
}
const int mm=2097152;
int sl;
const double dd=1/2097152;
double epsilon=1e-9;
int n,k;
double PI;
int a[1005];
bool d[5000005];
bool p[5000005];
comp pr[5000005];
comp u[5000005];
//comp v[5000005];
int reverse(int i,int m)
{
	int j=0;
	int l1=1;
	int l2=m>>1;
	while(l1<l2)
	{
		if((i&l1)>0) j+=l2;
		if((i&l2)>0) j+=l1;
		l1=l1<<1;
		l2=l2>>1;
	}
	if(l1==l2)
	{
		if((i&l1)) j+=l1;
	}
	return j;
}
inline void FFT(int m,bool nin)
{
	for(int i=0;i<m;i++)
	{
		int j=reverse(i,m);
		if(i<j) swap(pr[i],pr[j]);
	}
	comp x,y;
	comp w;
	comp d;
	d.x=1.0;
	d.y=0.0;
	for(int l=2;l<=m;l=l<<1)
	{
		w=polarcomp(1.0,2.0*PI/double(l));
		if(!nin) w=compinverse(w);
		for(int j=0;j<m;j=j+l)
		{
			d.x=1.0;
			d.y=0.0;
			for(int i=j;i<j+(l>>1);i++)
			{
				x=pr[i];
				y=pr[i+(l>>1)]*d;
				pr[i]=x+y;
				pr[i+(l>>1)]=x-y;
				d=d*w;
			}
		}
	}
}
void Multiply(bool nec)
{
	int m=0;
	for(int i=0;i<1000000;i++)
	{
		if((nec && d[i]) || p[i]) m=i;
	}
	m=m+10;
	double t=m;
	t=log(t)/log(2.0);
	m=t;
	m=pow(2,m+1);
	m=(m<<1);
	/*if(m>=2000000 && nec)
	{
		while(true)
		{
			m++;
		}
	}*/
	for(int i=0;i<m;i++)
	{
		pr[i].y=0.0;
		if(nec)
		{
			if(d[i]) pr[i].x=1.0;
			else pr[i].x=0.0;
		}
		else
		{
			if(p[i]) pr[i].x=1.0;
			else pr[i].x=0.0;
		}
	}
	FFT(m,true);
	for(int i=0;i<m;i++)
	{
		u[i]=pr[i];
		pr[i].y=0.0;
		if(p[i]) pr[i].x=1.0;
		else pr[i].x=0.0;
	}
	FFT(m,true);
	for(int i=0;i<m;i++) pr[i]=pr[i]*u[i];
	FFT(m,false);
	for(int i=0;i<m;i++)
	{
		if(pr[i].x>epsilon)
		{
			if(nec) d[i]=true;
			else p[i]=true;
		}
		else
		{
			if(nec) d[i]=false;
			else p[i]=false;
		}
	}
}
void Solve()
{
	int l=1;
	for(int i=0;i<n;i++) p[a[i]]=true;
	bool e=true;
	while(l<=k)
	{
		if((k&l)>0)
		{
			if(!e) Multiply(true);
			else
			{
				for(int i=0;i<=mm;i++) d[i]=p[i];
				e=false;
			}
		}
		Multiply(false);
		l=(l<<1);
	}
}
int main()
{
	PI=acos(-1);
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	Solve();
	for(int i=1;i<=1000000;i++) if(d[i]) printf("%d ",i);
	return 0;
}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 1;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N (1 << 20)
const double PI = acos(-1.0);

//O TAMANHO DOS VETORES DEVEM SER POTENCIAS DE 2
// Computes the DFT of vector v if type = 0, or the IDFT if type = 1
typedef complex<double> base;
void fft (vector<base> & a, bool invert) {
	int n = (int) a.size();

	for (int i=1, j=0; i<n; ++i) {
		int bit = n >> 1;
		for (; j>=bit; bit>>=1)
			j -= bit;
		j += bit;
		if (i < j)
			swap (a[i], a[j]);
	}

	for (int len=2; len<=n; len<<=1) {
		double ang = 2*PI/len * (invert ? -1 : 1);
		base wlen (cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w (1);
			for (int j=0; j<len/2; ++j) {
				base u = a[i+j],  v = a[i+j+len/2] * w;
				a[i+j] = u + v;
				a[i+j+len/2] = u - v;
				w *= wlen;
			}
		}
	}
	if (invert)
		for (int i=0; i<n; ++i)
			a[i] /= n;
}

void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res) {
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n = 1;
	while (n < max (a.size(), b.size()))  n <<= 1;
	n <<= 1;
	fa.resize (n),  fb.resize (n);

	fft (fa, false),  fft (fb, false);
	for (size_t i=0; i<n; ++i)
		fa[i] *= fb[i];
	fft (fa, true);

	res.resize (n);
	for (size_t i=0; i<n; ++i)
		res[i] = int (fa[i].real() + 0.5); //MAY GENERATE PROBLEMS WITH NEGATIVE NUMBERS
}

int v[1010];
vector<int> res,a;
int n,k;

void fast(int e) {
	res.resize(1024);
	a.resize(1024);
	res[0] = 1;
	for(int i=0;i<n;i++) {
		a[v[i]] = 1;
	}
	while(e) {
		if(e & 1) {
			multiply(res,a,res);
		}
		multiply(a,a,a);
		e >>= 1;
	}
}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i] != 0) {
			printf("%d ", i);
		}
	}
	cout << endl;

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 0;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N (1 << 20)
const double PI = acos(-1.0);

//O TAMANHO DOS VETORES DEVEM SER POTENCIAS DE 2
// Computes the DFT of vector v if type = 0, or the IDFT if type = 1
typedef complex<double> base;
void fft (vector<base> & a, bool invert) {
	int n = (int) a.size();
	for (int i=1, j=0; i<n; ++i) {
		int bit = n >> 1;
		for (; j>=bit; bit>>=1)
			j -= bit;
		j += bit;
		if (i < j)
			swap (a[i], a[j]);
	}
	for (int len=2; len<=n; len<<=1) {
		double ang = 2*PI/len * (invert ? -1 : 1);
		base wlen (cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w (1);
			for (int j=0; j<len/2; ++j) {
				base u = a[i+j],  v = a[i+j+len/2] * w;
				a[i+j] = u + v;
				a[i+j+len/2] = u - v;
				w *= wlen;
			}
		}
	}
	if (invert)
		for (int i=0; i<n; ++i)
			a[i] /= n;
}

void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res, int grauA = -1, int grauB = -1) {
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n = 1;
	if(grauA == -1 or grauB == -1) {
	    while (n <= a.size() + b.size())  n <<= 1;
	} else {
	    while (n <= grauA+grauB) n <<= 1;
	}

	fa.resize (n),  fb.resize (n);
	fft (fa, false),  fft (fb, false);
	for (size_t i=0; i<n; ++i)
		fa[i] *= fb[i];
	fft (fa, true);

	res.resize (n);
	for (size_t i=0; i<n; ++i)
		res[i] = int (fa[i].real() + 0.5); //MAY GENERATE PROBLEMS WITH NEGATIVE NUMBERS
}

int v[1010];
vector<int> res,a;
int n,k;

void fast(int e) {
    a.resize(1024);
	res.pb(1);
	int grauA, grauRes;
	grauRes = 1;
    grauA = 0;
	for(int i=0;i<n;i++) {
		a[v[i]] = 1;
		grauA = max(grauA,v[i]);
	}
	while(e) {
		if(e & 1) {
			multiply(res,a,res,grauRes, grauA);
			prin(res.size());
			grauRes += grauA;
			for(int i=0;i<res.size();i++)
			    if(res[i]) res[i] = 1;
			    else res[i] = 0;
		}
		multiply(a,a,a, grauA, grauA);
		grauA *= 2;
		prin(a.size());
		int maxi = 0;
		for(int i=0;i<a.size();i++) {
		    if(a[i]) {
		        maxi = i;
		        a[i] = 1;
		    } else a[i] = 0;
		}
		prin(maxi);
		e >>= 1;
	}
}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i] != 0) {
			printf("%d ", i);
		}
	}

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 0;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N 100100

//typedef complex<double> base;
typedef double ld;
const ld PI = acos(-1.0);
inline ld sqr(ld x) {return x*x;}
struct base {
    ld re, im;
    base() { }
	base(ld re) : re(re) { }
    base(ld re, ld im): re(re), im(im) { }
    ld slen() const { return sqr(re) + sqr(im); }
    ld real() { return re; }
};

inline base conj(const base& a) { return base(a.re, -a.im); }
inline base operator+ (const base& a, const base& b) { return base(a.re + b.re, a.im + b.im); }
inline base operator- (const base& a, const base& b) { return base(a.re - b.re, a.im - b.im); }
inline base operator* (const base& a, const base& b) { return base(a.re * b.re - a.im * b.im, a.re * b.im + a.im * b.re); }
inline base operator/ (const base& a, const ld& b) { return base(a.re / b, a.im / b); }
inline base operator/ (const base& a, const base& b) { return base(a.re * b.re + a.im * b.im, a.im * b.re - a.re * b.im) / b.slen(); }
inline base& operator/= (base& a, const ld& b) { a.re /= b, a.im /= b; return a; }

//Escrever a propria estrutura para complexos pode melhorar a complexidade em uns 20%
//O TAMANHO DOS VETORES DEVEM SER POTENCIAS DE 2
// Computes the DFT of vector v if type = 0, or the IDFT if type = 1

void fft (vector<base> & a, bool invert) {
	int n = (int) a.size();

	for (int i=1, j=0; i<n; ++i) {
		int bit = n >> 1;
		for (; j>=bit; bit>>=1)
			j -= bit;
		j += bit;
		if (i < j)
			swap (a[i], a[j]);
	}

	for (int len=2; len<=n; len<<=1) {
		ld ang = 2*PI/len * (invert ? -1 : 1);
		base wlen (cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w (1);
			for (int j=0; j<len/2; ++j) {
				base u = a[i+j],  v = a[i+j+len/2] * w;
				a[i+j] = u + v;
				a[i+j+len/2] = u - v;
				w = w * wlen;
			}
		}
	}
	if (invert)
		for (int i=0; i<n; ++i)
			a[i] /= n;
}

//Controlar o grau dos polinomios [e bem mais eficiente, senao pode acontecer do tamanho do resultado sempre dobrar, aumentando o tempo
void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res, int grauA = -1, int grauB = -1) {
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n = 1;
	if(grauA == -1 or grauB == -1) {
	    while (n <= max(a.size(),b.size()))  n <<= 1;
	} else {
	    while (n <= grauA+grauB) n <<= 1;
	}

	fa.resize (n),  fb.resize (n);
	fft (fa, false),  fft (fb, false);
	for (size_t i=0; i<n; ++i)
		fa[i] = fa[i] * fb[i];
	fft (fa, true);

	res.resize (n);

	ld aux = 0.5;
	prin(aux);
	for (size_t i=0; i<n; ++i)
		res[i] = int (fa[i].real() + aux); //MAY GENERATE PROBLEMS WITH NEGATIVE NUMBERS
}

int v[1010];
vector<int> res,a;
int n,k;

void fast(int e) {
    a.resize(1024);
	res.pb(1);
	int grauA, grauRes;
	grauRes = 1;
    grauA = 0;
	for(int i=0;i<n;i++) {
		a[v[i]] = 1;
		grauA = max(grauA,v[i]);
	}
	while(e) {
		if(e & 1) {
			multiply(res,a,res,grauRes, grauA);
			prin(res.size());
			grauRes += grauA;
			for(int i=0;i<res.size();i++)
			    if(res[i]) res[i] = 1;
			    else res[i] = 0;
		}
		multiply(a,a,a, grauA, grauA);
		grauA *= 2;
		prin(a.size());
		int maxi = 0;
		for(int i=0;i<a.size();i++) {
		    if(a[i]) {
		        maxi = i;
		        a[i] = 1;
		    } else a[i] = 0;
		}
		prin(maxi);
		e >>= 1;
	}
}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i] != 0) {
			printf("%d ", i);
		}
	}

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 1;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N (1 << 20)

typedef complex<double> Complex;
const double PI = acos(-1.0L);
//O TAMANHO DOS VETORES SAO ALTERADOS PARA POTENCIAS DE 2
// Computes the DFT of vector v if type = 1, or the IDFT if type = -1
vector<Complex> FFT(vector<Complex> &v, int type) {
    int n = v.size();
    while(n&(n-1)) { v.push_back(0); n++; }
    int logn = __builtin_ctz(n);
    vector<Complex> v2(n);
    for(int i=0; i<n; i++) {
        int mask = 0;
        for(int j=0; j<logn; j++) if(i&(1<<j)) mask |= (1<<(logn - 1 - j));
        v2[mask] = v[i];
    }
    for(int s=0, m=2; s<logn; s++, m<<=1) {
        Complex wm(cos(2.L * type * PI / m), sin(2.L * type * PI / m));
        for(int k=0; k<n; k+=m) {
            Complex w = 1;
            for(int j=0; 2*j<m; j++) {
                Complex t = w * v2[k + j + (m>>1)], u = v2[k + j];
                v2[k + j] = u + t; v2[k + j + (m>>1)] = u - t;
                w *= wm;
            }
        }
    }
    if(type == -1) for(Complex &c: v2) c /= n;
    return v2;
}

int v[1010];
vector<Complex> res,a;
int n,k;

void fast(int e) {

	res.resize(1024);
	a.resize(1024);
	res[0] = Complex(1.0,0.0);

	for(int i=0;i<n;i++) {
		a[v[i]] = Complex(1.0,0.0);
	}
	a = FFT(a,1);

	while(e > 0) {
		if(e & 1) {
			res.resize(a.size());
			res = FFT(res,1);
			for(int i=0;i<res.size();i++) {
				res[i] *= a[i];
			}
			res = FFT(res,-1);
		}

		a = FFT(a, -1);
		a.resize(2*a.size());
		a = FFT(a, 1);

		for(int i=0;i<a.size();i++) {
			a[i] *= a[i];
		}
		e /= 2;
	}

}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i].real() > eps) {
			printf("%d ", i);
		}
	}
	cout << endl;

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 0;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N 100100

//typedef complex<double> base;
typedef long double ld;
const ld PI = acos(-1.0);
inline ld sqr(ld x) {return x*x;}
struct base {
    ld re, im;
    base() {re = 0.0; im = 0.0;}
	base(ld re) : re(re) {im = 0.0;}
    base(ld re, ld im): re(re), im(im) { }
    ld slen() const { return sqr(re) + sqr(im); }
    ld real() { return re; }
};

inline base conj(const base& a) { return base(a.re, -a.im); }
inline base operator+ (const base& a, const base& b) { return base(a.re + b.re, a.im + b.im); }
inline base operator- (const base& a, const base& b) { return base(a.re - b.re, a.im - b.im); }
inline base operator* (const base& a, const base& b) { return base(a.re * b.re - a.im * b.im, a.re * b.im + a.im * b.re); }
inline base operator/ (const base& a, const ld& b) { return base(a.re / b, a.im / b); }
inline base operator/ (const base& a, const base& b) { return base(a.re * b.re + a.im * b.im, a.im * b.re - a.re * b.im) / b.slen(); }
inline base& operator/= (base& a, const ld& b) { a.re /= b, a.im /= b; return a; }

//Escrever a propria estrutura para complexos pode melhorar a complexidade em uns 20%
//O TAMANHO DOS VETORES DEVEM SER POTENCIAS DE 2
// Computes the DFT of vector v if type = 0, or the IDFT if type = 1

void fft (vector<base> & a, bool invert) {
	int n = (int) a.size();

	for (int i=1, j=0; i<n; ++i) {
		int bit = n >> 1;
		for (; j>=bit; bit>>=1)
			j -= bit;
		j += bit;
		if (i < j)
			swap (a[i], a[j]);
	}

	for (int len=2; len<=n; len<<=1) {
		ld ang = 2*PI/len * (invert ? -1 : 1);
		base wlen (cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w ((ld) 1);
			for (int j=0; j<len/2; ++j) {
				base u = a[i+j],  v = a[i+j+len/2] * w;
				a[i+j] = u + v;
				a[i+j+len/2] = u - v;
				w = w * wlen;
			}
		}
	}

	if (invert)
		for (int i=0; i<n; ++i)
			a[i] /= n;
}

//Controlar o grau dos polinomios [e bem mais eficiente, senao pode acontecer do tamanho do resultado sempre dobrar, aumentando o tempo
void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res, int grauA = -1, int grauB = -1) {
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n = 1;
	if(grauA == -1 or grauB == -1) {
	    while (n < max(a.size(),b.size()))  n <<= 1;
		n <<= 1;
	} else {
	    while (n <= grauA+grauB) n <<= 1;
	}

	fa.resize (n),  fb.resize (n);
	fft (fa, false),  fft (fb, false);
	for (size_t i=0; i<n; ++i)
		fa[i] = fa[i] * fb[i];
	fft (fa, true);

	res.resize (n);

	ld aux = 0.5;
	for (size_t i=0; i<n; ++i)
		res[i] = int (fa[i].real() + aux); //MAY GENERATE PROBLEMS WITH NEGATIVE NUMBERS
}

int v[1010];
vector<int> res,a;
int n,k;

void fast(int e) {
    a.resize(1024);
	res.pb(1);
	int grauA, grauRes;
	grauRes = 1;
    grauA = 0;
	for(int i=0;i<n;i++) {
		a[v[i]] = 1;
		grauA = max(grauA,v[i]);
	}
	while(e) {
		if(e & 1) {
			multiply(res,a,res,grauRes, grauA);
			prin(res.size());
			grauRes += grauA;
			for(int i=0;i<res.size();i++)
			    if(res[i]) res[i] = 1;
			    else res[i] = 0;
		}
		multiply(a,a,a, grauA, grauA);
		grauA *= 2;
		prin(a.size());
		int maxi = 0;
		for(int i=0;i<a.size();i++) {
		    if(a[i]) {
		        maxi = i;
		        a[i] = 1;
		    } else a[i] = 0;
		}
		prin(maxi);
		e >>= 1;
	}
}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i] != 0) {
			printf("%d ", i);
		}
	}

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 1;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N (1 << 20)
const double PI = acos(-1.0);

//O TAMANHO DOS VETORES DEVEM SER POTENCIAS DE 2
// Computes the DFT of vector v if type = 0, or the IDFT if type = 1
typedef complex<double> base;
void fft (vector<base> & a, bool invert) {
	int n = (int) a.size();
	for (int i=1, j=0; i<n; ++i) {
		int bit = n >> 1;
		for (; j>=bit; bit>>=1)
			j -= bit;
		j += bit;
		if (i < j)
			swap (a[i], a[j]);
	}
	for (int len=2; len<=n; len<<=1) {
		double ang = 2*PI/len * (invert ? -1 : 1);
		base wlen (cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w (1);
			for (int j=0; j<len/2; ++j) {
				base u = a[i+j],  v = a[i+j+len/2] * w;
				a[i+j] = u + v;
				a[i+j+len/2] = u - v;
				w *= wlen;
			}
		}
	}
	if (invert)
		for (int i=0; i<n; ++i)
			a[i] /= n;
}

void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res) {
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n = 1;
	while (n < max (a.size(), b.size()))  n <<= 1;
	n <<= 1;
	fa.resize (n),  fb.resize (n);

	fft (fa, false),  fft (fb, false);
	for (size_t i=0; i<n; ++i)
		fa[i] *= fb[i];
	fft (fa, true);

	res.resize (n);
	for (size_t i=0; i<n; ++i)
		res[i] = int (fa[i].real() + 0.5); //MAY GENERATE PROBLEMS WITH NEGATIVE NUMBERS
}

int v[1010];
vector<int> res,a;
int n,k;

void fast(int e) {
	a.resize(1024);
	res.pb(1);
	for(int i=0;i<n;i++) {
		a[v[i]] = 1;
	}
	while(e) {
		if(e & 1) {
			multiply(res,a,res);
		}
		multiply(a,a,a);
		e >>= 1;
	}
}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i] != 0) {
			printf("%d ", i);
		}
	}

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 0;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N 100100

//typedef complex<double> base;
typedef double ld;
const ld PI = acos(-1.0);
inline ld sqr(ld x) {return x*x;}
struct base {
    ld re, im;
    base() {re = 0.0; im = 0.0;}
	base(ld re) : re(re) {im = 0.0;}
    base(ld re, ld im): re(re), im(im) { }
    ld slen() const { return sqr(re) + sqr(im); }
    ld real() { return re; }
};

inline base conj(const base& a) { return base(a.re, -a.im); }
inline base operator+ (const base& a, const base& b) { return base(a.re + b.re, a.im + b.im); }
inline base operator- (const base& a, const base& b) { return base(a.re - b.re, a.im - b.im); }
inline base operator* (const base& a, const base& b) { return base(a.re * b.re - a.im * b.im, a.re * b.im + a.im * b.re); }
inline base operator/ (const base& a, const ld& b) { return base(a.re / b, a.im / b); }
inline base operator/ (const base& a, const base& b) { return base(a.re * b.re + a.im * b.im, a.im * b.re - a.re * b.im) / b.slen(); }
inline base& operator/= (base& a, const ld& b) { a.re /= b, a.im /= b; return a; }

//Escrever a propria estrutura para complexos pode melhorar a complexidade em uns 20%
//O TAMANHO DOS VETORES DEVEM SER POTENCIAS DE 2
// Computes the DFT of vector v if type = 0, or the IDFT if type = 1

void fft (vector<base> & a, bool invert) {
	int n = (int) a.size();

	for (int i=1, j=0; i<n; ++i) {
		int bit = n >> 1;
		for (; j>=bit; bit>>=1)
			j -= bit;
		j += bit;
		if (i < j)
			swap (a[i], a[j]);
	}

	for (int len=2; len<=n; len<<=1) {
		ld ang = 2*PI/len * (invert ? -1 : 1);
		base wlen (cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w ((ld) 1);
			for (int j=0; j<len/2; ++j) {
				base u = a[i+j],  v = a[i+j+len/2] * w;
				a[i+j] = u + v;
				a[i+j+len/2] = u - v;
				w = w * wlen;
			}
		}
	}

	if (invert)
		for (int i=0; i<n; ++i)
			a[i] /= n;
}

//Controlar o grau dos polinomios [e bem mais eficiente, senao pode acontecer do tamanho do resultado sempre dobrar, aumentando o tempo
void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res, int grauA = -1, int grauB = -1) {
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n = 1;
	if(grauA == -1 or grauB == -1) {
	    while (n < max(a.size(),b.size()))  n <<= 1;
		n <<= 1;
	} else {
	    while (n <= grauA+grauB) n <<= 1;
	}

	fa.resize (n),  fb.resize (n);
	fft (fa, false),  fft (fb, false);
	for (size_t i=0; i<n; ++i)
		fa[i] = fa[i] * fb[i];
	fft (fa, true);

	res.resize (n);

	ld aux = 0.5;
	for (size_t i=0; i<n; ++i)
		res[i] = int (fa[i].real() + aux); //MAY GENERATE PROBLEMS WITH NEGATIVE NUMBERS
}

int v[1010];
vector<int> res,a;
int n,k;

void fast(int e) {
    a.resize(1024);
	res.pb(1);
	int grauA, grauRes;
	grauRes = 1;
    grauA = 0;
	for(int i=0;i<n;i++) {
		a[v[i]] = 1;
		grauA = max(grauA,v[i]);
	}
	while(e) {
		if(e & 1) {
			multiply(res,a,res,grauRes, grauA);
			prin(res.size());
			grauRes += grauA;
			for(int i=0;i<res.size();i++)
			    if(res[i]) res[i] = 1;
			    else res[i] = 0;
		}
		multiply(a,a,a, grauA, grauA);
		grauA *= 2;
		prin(a.size());
		int maxi = 0;
		for(int i=0;i<a.size();i++) {
		    if(a[i]) {
		        maxi = i;
		        a[i] = 1;
		    } else a[i] = 0;
		}
		prin(maxi);
		e >>= 1;
	}
}

int main () {

	scanf("%d %d", &n, &k);

	for(int i=0;i<n;i++) {
		scanf("%d", &v[i]);
	}

	fast(k);

	for(int i=0;i<res.size();i++) {
		if(res[i] != 0) {
			printf("%d ", i);
		}
	}

	return 0;

}


#include <bits/stdc++.h>
#define FILE_IN freopen("in", "r", stdin);
#define FILE_OUT freopen("out", "w", stdout);
bool debug = 1;
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define rang(a,b) if(debug) printf("%d -> %d\n", (a), (b))
#define separa() if(debug) cout << endl
#define fr(i,n) for(int i = 0; i<(n); i++)
#define frr(i,a,b) for(int i = (a); i<=(b);i++)
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
#define MOD 1000000007
const double eps = 1e-9;
using namespace std;
#define N (1 << 20)

typedef complex<double> Complex;
const double PI = acos(-1.0L);
//O TAMANHO DOS VETORES SAO ALTERADOS PARA POTENCIAS DE 2
// Computes the DFT of vector v if type = 1, or the IDFT if type = -1
vector<Complex> FFT(vector<Complex> &v, int type) {
    int n = v.size();
    while(n&(n-1)) { v.push_back(0); n++; }
    int logn = __builtin_ctz(n);
    vector<Complex> v2(n);
    for(int i=0; i<n; i++) {
        int mask = 0;
        for(int j=0; j<logn; j++) if(i&(1<<j)) mask |= (1<<(logn - 1 - j));
        v2[mask] = v[i];
    }
    for(int s=0, m=2; s<logn; s++, m<<=1) {
        Complex wm(cos(2.L * type * PI / m), sin(2.L * type * PI / m));
        for(int k=0; k<n; k+=m) {
            Complex w = 1;
            for(int j=0; 2*j<m; j++) {
                Complex t = w * v2[k + j + (m>>1)], u = v2[k + j];
                v2[k + j] = u + t; v2[k + j + (m>>1)] = u - t;
                w *= wm;
            }
        }
    }
    if(type == -1) for(Complex &c: v2) c /= n;
    return v2;
}

int v[N];
vector<Complex> res,a;
int n,k;

void fast(int e) {

	res.resize(N);
	a.resize(N);
	res[0] = Complex(1.0,0.0);

	for(int i=0;i<n;i++) {
		a[v[i]] = Complex(1.0,0.0);
	}
	res = FFT(res,1);
	a = FFT(a,1);

	while(e > 0) {
		if(e & 1) {
			for(int i=0;i<res.size();i++) {
				res[i] *= a[i];
			}
		}
		for(int i=0;i<a.size();i++) {
			a[i] *= a[i];
		}
		e /= 2;
	}

	res = FFT(res, -1);

}

int main () {

	cin >> n >> k;

	for(int i=0;i<n;i++) {
		cin >> v[i];
	}

	fast(k);

	for(int i=0;i<N;i++) {
		if(res[i].real() > eps) {
			printf("%d ", i);
		}
	}
	cout << endl;

	return 0;

}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(22) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()]=1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{

			if (k & 1)
			{
				b = a;
				d = c;
				N.convolve(b, d, c);
				for (int i = 0; i < c.size(); i++)
					if (c[i])
						c[i] = 1;
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(440564289) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2-1);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()]=1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{

			if (k & 1)
			{
				b = a;
				d = c;
				N.convolve(b, d, c);
				for (int i = 0; i < c.size(); i++)
					if (c[i])
						c[i] = 1;
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(440564289) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()]=1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{

			if (k & 1)
			{
				b = a;
				d = c;
				N.convolve(b, d, c);
				for (int i = 0; i < c.size(); i++)
					if (c[i])
						c[i] = 1;
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(22) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		long long INV = inv_(1 << depth, MOD);
		for (auto &x : a)
		{
			x =(INV*x)%MOD;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()]=1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{

			if (k & 1)
			{
				b = a;
				d = c;
				N.convolve(b, d, c);
				for (int i = 0; i < c.size(); i++)
					if (c[i])
						c[i] = 1;
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(440564289) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2-1);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()] = 1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{

			if (k & 1)
			{
				b = a;
				d = c;
				N.convolve(b, d, c);
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(440564289) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2-1);
		while (a.size()<SZ)
		{
			a.push_back(0);
		}
		while (b.size()<SZ)
		{
			b.push_back(0);
		}
		while (c.size()<SZ)
		{
			c.push_back(0);
		}
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()]=1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{

			if (k & 1)
			{
				b = a;
				d = c;
				N.convolve(b, d, c);
				for (int i = 0; i < c.size(); i++)
					if (c[i])
						c[i] = 1;
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(440564289) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2-1);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<long long> N;
		ve<long long> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()] = 1;
		}
		ve<long long> b, c(1,1),d;
		while (k)
		{
			b = a;
			if (k & 1)
			{
				N.convolve(c, b, c);
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <ctime>
#include <deque>
#include <bitset>
#include <vector>
#include <list>
#include <stack>
#include <random>
#include <string>
#include <numeric>      //  needed for  accumulate
#include <utility>     // needed for std:: move
#include <iterator>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(),x.end())
#define mod static_cast<long long> (1e9+9)
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define int2 int64_t
#define pi 3.14159265358979323846
#define testing 0
#define code_chef 0
#define code_jam 0
#define getcx getchar
using namespace std;
template<typename T>
T max(T A)
{
	return A;
}
template<typename T, typename... args>
T max(T A, T B, args... S)
{
	return max(A > B ? A : B, S...);
}
template<typename T>
T min(T A)
{
	return A;
}
template<typename T, typename... args>
T min(T A, T B, args... S)
{
	return min(A > B ? A : B, S...);
}
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		scanf("%d", &x);
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		printf("%d ", x);
	return in;
}
long long fast(long long a, long long b, long long pr)
{
	if (b == 0)
		return 1 % pr;
	long long ans = 1 % pr;
	while (b)
	{
		if (b & 1)
		{
			ans *= a;
			ans %= pr;
		}
		b >>= 1;
		a *= a;
		a %= pr;
	}
	return ans;
}
int readInt()
{
	int n = 0;
	scanf("%d", &n);
	return n;
	int ch = getcx(); int sign = 1;
	while (ch < '0' || ch > '9') { if (ch == '-')sign = -1; ch = getcx(); }

	while (ch >= '0' && ch <= '9')
		n = (n << 3) + (n << 1) + ch - '0', ch = getcx();
	n = n*sign;
	return n;
}
long long inv_(long long val, long long Pr)
{
	return fast(val, Pr - 2, Pr);
}
template<typename T>
class NTT
{
	ve<int> bit_reverse;
	int SZ, depth;
	 long long MOD;
	 long long ROOT; // MOD == 15*(1<<27)+1 (prime)
public:
	NTT() :MOD(2013265921), ROOT(440564289) {}
	void prepare(int pre)
	{
		SZ = 1;
		depth = 0;
		--pre;
		while (pre)
		{
			SZ <<= 1;
			++depth;
			pre >>= 1;
		}
		bit_reverse.resize(SZ);
		bit_reverse[0] = 0;
		bit_reverse[1] = SZ >> 1;
		for (int i = 1; i + 1<SZ; i++)
		{
			if ((i << 1)<SZ)
				bit_reverse[i << 1] = bit_reverse[i] >> 1;
			if ((i & 1) == 0)
			{
				bit_reverse[i + 1] = bit_reverse[i] | (SZ >> 1);
			}
		}
	}
	void ntt(vector<T> &a, int root)
	{
		for (int i = 0; i < SZ; i++)
			if (bit_reverse[i] < i)
				swap(a[i], a[bit_reverse[i]]);
		for (int i = 1; i<SZ; i <<= 1)
		{
			// ROOT**i=(1<<27)*15
			long long w = fast(root, (MOD - 1) / (i<<1), MOD);
			for (int j = 0; j<SZ; j += (i << 1))
			{
				long long w0 = 1;
				for (int k = 0; k<i; k++)
				{
					long long V = a[k + j];
					long long W = (w0*a[k + j + i]) % MOD;
					a[k + j] = (V + W)%MOD;
					a[k + j + i] = (V - W+MOD)%MOD;
					w0 *= w;
					w0 %= MOD;
				}
			}
		}
	}
	void ntt_inverse(vector<T> &a)
	{
		ntt(a, inv_(ROOT, MOD));
		for (auto &x : a)
		{
			x >>= depth;
		}
	}
	void convolve(ve<T> &a, vector<T> &b, vector<T> &c)// a0+a1x+a2x2    a.b= c
	{
		prepare(max(a.size(), b.size())*2-1);
		a.resize(SZ);
		b.resize(SZ);
		c.resize(SZ);
		ntt(a, ROOT);
		ntt(b, ROOT);
		for (int i = 0; i<SZ; i++)
		{
			c[i] = (a[i] * (b[i]*1LL))%MOD;
		}
		ntt_inverse(c);
	}
};
// Code code code
class solve
{

public:
	solve()
	{
		int n, k;
		cin >> n >> k;
		NTT<int> N;
		ve<int> a(1001);
		for (int i = 0; i < n; i++)
		{
			a[readInt()] = 1;
		}
		ve<int> b, c(1,1);
		while (k)
		{
			b = a;
			if (k & 1)
			{
				N.convolve(c, b, c);
			}
			b = a;
			N.convolve(b, a, a);
			k >>= 1;
		}
		for (int i = 0; i < c.size(); i++)
		{
			if (c[i])
			{
				cout << i << " ";
			}
		}
	}
};
int32_t main()
{
	int t = 1, i = 1;
	//freopen("c2:\\Users\\Xenor\\Downloads\\b2.in","r",stdin);
	//freopen("c2:\\Users\\Xenor\\Downloads\\gb2.txt","w",stdout);
	if (code_chef)
		scanf("%d", &t);
	while (t--)
	{
		if (code_jam)
			printf("Case #%d: ", i++);
		new solve;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const int N = 5e6 + 20;
const int inf = 1e9 + 7;
int mod = 7340033;
ll root = 5;
ll revroot = 4404020;
int md = 20;

ll c[N];

inline ll power(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1) ans = (ans * x) % mod;
		x = (x * x) % mod;
		y /= 2;
	}
	re ans;
}

inline int rev(int x, int p) {
	int ans = 0;
	for (int i = 0; i < p; i++)
		ans = ans * 2 + (x & 1), x /= 2;
	re ans;
}

void step(int k, ll* a, ll* b, int n, bool inv)
{
    int h = n >> 1;
    int m = n >> k;
    ll u, v, r = 1;
    int c = m;
    ll w = (inv) ? revroot : root;
	w = power(w, (1 << (md - k)));
    for (int i = 0; i < h; i++) {
        u = a[i << 1];
        v = r * a[(i << 1) | 1] % mod;
        b[i] = (u + v) % mod;
        b[i + h] = (u - v + mod) % mod;
        if (!--c) {
            c = m;
            r = r * w % mod;
        }
    }
}

void fft(ll* a, int p, bool inv)
{
	int n = 1 << p;
    for (int i = 0; i < n; i++) {
    	int x = rev(i, p);
        if (x > i)
            swap(a[i], a[x]);
	}
    for (int i = 1; i <= p; i++)
        if (i & 1) step(i, a, c, n, inv);
        else step(i, c, a, n, inv);
    if (p & 1)
        memcpy(a, c, n * sizeof(c[0]));
	if (inv) {
		ll x = power(n, mod - 2);
		for (int i = 0; i < n; i++)
			a[i] = (a[i] * x) % mod;
	}
}

int n, m;
ll a[N], b[N];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		a[x] = 1;
		b[x] = 1;
	}
	int s = (1 << 20);
	int p = 20;
	fft(a, p, false);
	for (int i = 0; i < s; i++)
		a[i] = power(a[i], m);
	fft(a, p, true);
	md = 23;
	mod = 998244353;
	root = 15311432;
	revroot = 469870224;
	fft(b, p, false);
	for (int i = 0; i < s; i++)
		b[i] = power(b[i], m);
	fft(b, p, true);
	for (int i = 0; i < s; i++)
		if (b[i] || a[i])
			printf("%d ", i);
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const int N = 5e6 + 20;
const int inf = 1e9 + 7;
const int mod = 998244353;
const ll root = 15311432;
const ll revroot = 469870224;

ll c[N];

inline ll power(ll x, ll y) {
	ll ans = 1;
	while (y) {
		if (y & 1) ans = (ans * x) % mod;
		x = (x * x) % mod;
		y /= 2;
	}
	re ans;
}

inline int rev(int x, int p) {
	int ans = 0;
	for (int i = 0; i < p; i++)
		ans = ans * 2 + (x & 1), x /= 2;
	re ans;
}

void step(int k, ll* a, ll* b, int n, bool inv)
{
    int h = n >> 1;
    int m = n >> k;
    ll u, v, r = 1;
    int c = m;
    ll w = (inv) ? revroot : root;
	w = power(w, (1 << (23 - k)));
    for (int i = 0; i < h; i++) {
        u = a[i << 1];
        v = r * a[(i << 1) | 1] % mod;
        b[i] = (u + v) % mod;
        b[i + h] = (u - v + mod) % mod;
        if (!--c) {
            c = m;
            r = r * w % mod;
        }
    }
}

void fft(ll* a, int p, bool inv)
{
	int n = 1 << p;
    for (int i = 0; i < n; i++) {
    	int x = rev(i, p);
        if (x > i)
            swap(a[i], a[x]);
	}
    for (int i = 1; i <= p; i++)
        if (i & 1) step(i, a, c, n, inv);
        else step(i, c, a, n, inv);
    if (p & 1)
        memcpy(a, c, n * sizeof(c[0]));
	if (inv) {
		ll x = power(n, mod - 2);
		for (int i = 0; i < n; i++)
			a[i] = (a[i] * x) % mod;
	}
}

int n, m;
ll a[N];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		a[x]++;
	}
	int s = (1 << 20);
	int p = 20;
	fft(a, p, false);
	for (int i = 0; i < s; i++)
		a[i] = power(a[i], m);
	fft(a, p, true);
	for (int i = 0; i < s; i++)
		if (a[i])
			printf("%d ", i);
	return 0;
}


<?php
$kill=array();
$replace=array();
fscanf(STDIN,"%s %s",$kill[0],$replace[0]);	# code...

fscanf(STDIN,"%d",$day);

for ($i=1; $i <=$day ; $i++)
{
        fscanf(STDIN,"%s %s",$kill[$i],$replace[$i]);	# code...
}
echo "$kill[0] $replace[0]\n";
$newKill=$kill[0];
$newRep=$replace[0];

for ($i=1; $i <= $day ; $i++)
{
   //echo $i." ".$kill[$i].' '.$newKill." before if ".$kill[$i].' '.$newRep."\n";

  if ($kill[$i]==$newKill)
   {
   	$newKill=$replace[$i];
   	//$newRep=$replace[$i-1];
      echo $newKill." ".$newRep."\n";

   }
   else
   {
    	$newRep=$replace[$i];
    	//$newKill=$newKill;
      echo $newKill." ".$newRep."\n";

    }

}
/*
echo "All input shown\n";
//var_dump($initial);
echo "day=$day\n";
echo "kill\n";
var_dump($kill);
echo "replace\n";
var_dump($replace);
*/


<?php
$kill=array();
$replace=array();
fscanf(STDIN,"%s %s",$kill[0],$replace[0]);	# code...

fscanf(STDIN,"%d",$day);

for ($i=1; $i <=$day ; $i++)
{
        fscanf(STDIN,"%s %s",$kill[$i],$replace[$i]);	# code...
}
echo "output:\n$kill[0] $replace[0]\n";
$newKill=$kill[0];
$newRep=$replace[0];

for ($i=1; $i <= $day ; $i++)
{
   //echo $i." ".$kill[$i].' '.$newKill." before if ".$kill[$i].' '.$newRep."\n";

  if ($kill[$i]==$newKill)
   {
   	$newKill=$replace[$i];
   	//$newRep=$replace[$i-1];
      echo $newKill." ".$newRep."\n";

   }
   else
   {
    	$newRep=$replace[$i];
    	//$newKill=$newKill;
      echo $newKill." ".$newRep."\n";

    }

}
/*
echo "All input shown\n";
//var_dump($initial);
echo "day=$day\n";
echo "kill\n";
var_dump($kill);
echo "replace\n";
var_dump($replace);
*/


<?php
$kill=array();
$replace=array();
fscanf(STDIN,"%s %s",$kill[0],$replace[0]);	# code...

fscanf(STDIN,"%d",$day);

for ($i=1; $i <=$day ; $i++)
{
        fscanf(STDIN,"%s %s",$kill[$i],$replace[$i]);	# code...
}
echo "output:\n$kill[0] $replace[0]\n";
$newKill=$kill[0];
$newRep=$replace[0];

for ($i=1; $i <= $day ; $i++)
{
   //echo $kill[$i].' '.$newKill." before if ".$kill[$i].' '.$newRep."\n";

  if ($kill[$i]==$newKill)
   {
   	$newKill=$replace[$i];
   	$newRep=$replace[$i-1];
      echo $newKill." ".$newRep."\n";

   }
   if($kill[$i]==$newRep)
    {
    	$newRep=$replace[$i];
      echo $newKill." ".$newRep."\n";

    }

}
/*
echo "All input shown\n";
//var_dump($initial);
echo "day=$day\n";
echo "kill\n";
var_dump($kill);
echo "replace\n";
var_dump($replace);
*/


now_list = raw_input().split(' ')
n = int(raw_input())
print ' '.join(now_list)
for i in xrange(n):
    x, y = raw_input().split(' ')
    now_list.remove(x)
    now_list.append(y)
    print ' '.join(now_list)


import sys

victims = sys.stdin.readline().strip()
days = int(sys.stdin.readline().strip())
print(victims)

for day in range(days):
  newVictims = sys.stdin.readline().strip().split()
  victims = victims.replace(newVictims[0], newVictims[1])
  print(victims)


import sys

victims = sys.stdin.readline().strip()
days = int(sys.stdin.readline().strip())
print(victims)

for day in range(days):
  newVictims = sys.stdin.readline().split()
  victims = victims.replace(newVictims[0], newVictims[1])
  print(victims)