1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2*3*1e5;
const int INF=1e9+7;
int A,B,C;
int n=0;
map<tuple<int,int,int>,int> mp;
tuple<int,int,int> ver[N+10];
int d[N+10];
int ans[N+10];
bool vis[N+10];
queue<int> que;
bool ok(int a,int b,int c)
{
	return (a>=0 && b>=0 && c>=0 && a<=A && b<=B && c<=C);
}
void add(int a,int b,int c)
{
	if(ok(a,b,c) && mp.find({a,b,c})==mp.end())
	{
		n++;
		mp[make_tuple(a,b,c)]=n;
		ver[n]=make_tuple(a,b,c);
	}
	return;
}
vector<int> gen_e(int a,int b,int c)
{
	vector<int> vec;
	auto add_ver=[&vec](int x,int y,int z)
	{
		//cerr<<x<<" "<<y<<" "<<z<<"\n";
		if(ok(x,y,z))
			vec.push_back(mp[make_tuple(x,y,z)]);
		return;
	};

	int T[3]={A,B,C};
	auto mv=[&](int x,int y)
	{
		int t[3]={a,b,c};
		int dd=min(t[x],T[y]-t[y]);
		t[x]-=dd;
		t[y]+=dd;
		add_ver(t[0],t[1],t[2]);
		return;
	};

	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
			mv(i,j);
	}

	//cerr<<a<<" "<<b<<" "<<c<<"\n";
	//for(auto v:vec)
	//{
	//	auto [a1,a2,a3]=ver[v];
	//	cerr<<a1<<" "<<a2<<" "<<a3<<"\n";
	//}
	//cerr<<"\n";

	return vec;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b,c;
	cin>>A>>B>>C;
	cin>>a>>b>>c;
	int s=a+b+c;
	add(a,b,c);
	for(int i=0;i<=C;i++)
	{
		add(0,i,s-i);
		add(A,i,s-i-A);

		add(i,0,s-i);
		add(i,B,s-i-B);

		add(i,s-i,0);
		add(i,s-i-C,C);

		ans[i]=INF;
	}
	vis[1]=true;
	d[1]=0;
	que.push(1);
	while(!que.empty())
	{
		int x=que.front();
		que.pop();
		auto [a1,a2,a3]=ver[x];
		auto e=gen_e(a1,a2,a3);
		for(auto v:e)
		{
			if(!vis[v])
			{
				vis[v]=true;
				d[v]=d[x]+1;
				que.push(v);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			continue;
		auto [a1,a2,a3]=ver[i];
		for(auto j:{a1,a2,a3})
			ans[j]=min(ans[j],d[i]);
	}
	for(int i=0;i<=C;i++)
		cout<<(ans[i]==INF ? -1:ans[i])<<" ";
	cout<<"\n";
	return 0;
}