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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <map> 
#include <string>
#include <vector>  
#include <iostream> 
#include <sstream> 
#include <queue>
#include <algorithm>
#include <assert.h>


using namespace std;

#define ll long long
#define PB 		push_back
#define FOR(a,start,end) 	for(int a=int(start); a<int(end); a++)
#define INF 		INT_MAX
#define SORT(a) 	sort(a.begin(),a.end()) 
#define CL(a,x) 		memset(a,x,sizeof(a))
#define REP(a,x)	for(int a=0;a<x;a++)
#define REP1(a,x)	for(int a=1;a<=x;a++)
#define MP 		make_pair



typedef vector<ll>     vi;
typedef pair<ll, ll>     pii;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vector<ll> > vvi;
typedef vector<vector<string> > vvs;
typedef vector<pair<string, string> > vss;
typedef pair<string, string> pss;
typedef pair<ll, pii> ppii;
typedef vector<ppii> vppii;
typedef vector<vector<pii> > vvii;
typedef vector<vvi> vvvi;


ll b1, n, k, a, b, c, z, m, d, t, m2, s;

vi vk, va, vb, vc;
vvi vva1,vva2;
vii vkx;
string w1, w2;
map<ll, int> vm;
map<ll, int>::iterator it;
bool dod(vi vb) {
	ll g = vb[0] + 100000 * vb[1] + 10000000000 * vb[2];
	if (vm.find(g) == vm.end()) {
		vm[g] = 1;
		return true;
	}
	return false;
}

vvi next(vi vb) {
	vvi vva;
	vva.clear();
	vi vb0 = vb;
	int d;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < i + 3; j++) {
			d = min(vb[i], va[j % 3] - vb[j % 3]);
			vb[j % 3] += d;
			vb[i] -= d;
			if (dod(vb))
				vva.push_back(vb);
			vb[j % 3] -= d;
			vb[i] += d;
		}
	}
	return vva;
}
int iler(vi vb) {
	if (vb[0] == vb[1]) {
		if (vb[1] == vb[2]) {
			return 1;
		}
		return 2;
	}
	else if (vb[2] == vb[1]) {
		return 2;
	}
	else if (vb[2] == vb[0]) {
		return 2;
	}
	return 3;
}
int main() {
	//freopen("c:\\wojtek\\uva\\pa\\debug\\t1.in.txt", "rt", stdin);

//	while (1) {
	vm.clear();
	va.assign(3, 0);
	vb.assign(3, 0);
	cin >> va[0] >> va[1] >> va[2];
	cin >> vb[0] >> vb[1] >> vb[2];
	vc.assign(va[2] + 1, -1);
	vc[vb[0]] = 0;
	vc[vb[1]] = 0;
	vc[vb[2]] = 0;
	
	vva1.clear();
	vva2.clear();
	vva1.push_back(vb);
	k = iler(vb);
	t = 0;
	while ((k < va[2] + 1)&&(vva1.size()>0)) {
		t++;
		for (int i = 0; i < vva1.size(); i++) {
			vb = vva1[i];
			vvi vvb = next(vb);
			for (int j = 0; j < vvb.size(); j++) {
				for (int i1 = 0; i1 < 3; i1++) {
					if (vc[vvb[j][i1]] < 0) {
						vc[vvb[j][i1]] = t;
						k++;
					}
				}
				vva2.push_back(vvb[j]);
			}
		}
		vva1.swap(vva2);
		vva2.clear();
	}
	for (int i = 0; i <= va[2]; i++) {
		cout << vc[i] << " ";
	}
	
	//	}

	return 0;

}