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
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = b; a <= i; i--)
#define cat(x) cerr << #x << " = " << x << '\n';
using ll = long long;
using namespace std;

int a[3], b[3], res[100100];
map<array<int, 3>, int> dis;
queue<array<int, 3>> q;

int main() {
	cin.tie(0)->sync_with_stdio(0);

	cin >> b[0] >> b[1] >> b[2];
	cin >> a[0] >> a[1] >> a[2];

	dis[{a[0], a[1], a[2]}] = 0;
	q.push({a[0], a[1], a[2]});

	while (!q.empty()) {
		auto f = q.front();
		q.pop();
		rep(i, 0, 2) {
			rep(j, 0, 2) {
				int c = min(f[i], b[j] - f[j]);
				auto g = f;
				g[i] -= c;
				g[j] += c;
				if (dis.count(g) == 0) {
					dis[g] = dis[f] + 1;
					q.push(g);
				}
			}
		}
	}

	rep(i, 0, b[2])
		res[i] = 1e9;

	for (auto [t, d] : dis) {
		rep(i, 0, 2)
			res[t[i]] = min(res[t[i]], d);
	}

	rep(i, 0, b[2])
		cout << (res[i] == 1e9 ? -1 : res[i]) << ' ';

	return 0;
}