package yukicoder317; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args){ PrintWriter pw=new PrintWriter(System.out); Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); DJSet ds=new DJSet(n); for(int i=0;i0;d*=2){ int x=Math.min(f[i],d); f[i]-=x;//辺数iのグラフがf[i]個ある。 sum+=x*i; for(int j=sum;j>=x*i;j--){ dp[j]=Math.min(dp[j], dp[j-x*i]+x); } } } for(int i=0;i<=n;i++){ if(dp[i]>1000000)dp[i]=0; } for(int i=1;i<=n;i++){ pw.println(dp[i]-1); } pw.close(); } public static class DJSet{ public int[] upper; public DJSet(int n){ upper=new int[n]; Arrays.fill(upper, -1); } public int root(int x){ return upper[x]<0? x:root(upper[x]); } public boolean equiv(int x,int y){ return root(x)==root(y); } public boolean union(int x,int y){ x=root(x); y=root(y); if(x!=y){ if(upper[y]