package zhenti;
import java.util.ArrayList;
import java.util.Scanner;
public class daoyou {
static int rongqishuliang = 3;
static boolean isfouchenggong = false;
static int mubiao = 0;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
rongqi rongqis[] = new rongqi[3];
int templist[][] = new int[2][rongqishuliang];
for (int i = 0; i < templist.length; i++) {
for (int j = 0; j < templist[0].length; j++) {
templist[i][j] = scanner.nextInt();
}
}
mubiao = scanner.nextInt();
scanner.close();
for (int i = 0; i < rongqishuliang; i++) {
rongqis[i] = new rongqi(templist[0][i], templist[1][i]);
}
Integer list[] = new Integer[3];
for (int i = 0; i < list.length; i++) {
list[i] = rongqis[i].cunliang;
}
ArrayList<Integer[]> arrayList = new ArrayList<>();
arrayList.add(list);
daoyoufanfa(rongqis, arrayList);
}
public static boolean nengfoucharu(ArrayList<Integer[]> arrayList, Integer[] list) {
for (int i = 0; i < arrayList.size(); i++) {
Integer[] temp = arrayList.get(i);
if (shifouxiangdeng(temp, list)) {
return false;
}
}
return true;
}
public static boolean shifouxiangdeng(Integer[] list1, Integer[] list2) {
int length = list1.length;
for (int i = 0; i < list2.length; i++) {
if (list1[i] != list2[i]) {
return false;
}
}
return true;
}
public static boolean jiance(rongqi[] rongqis, int rongqishuliang ) {
for (int i = 0; i < rongqishuliang; i++) {
if (rongqis[i].cunliang == mubiao) {
return true;
}
}
return false;
}
public static void daoyoufanfa(rongqi[] rongqis ,ArrayList<Integer[]> arrayList) {
if(jiance(rongqis, rongqishuliang)) {
isfouchenggong = true;
for (int i = 0; i < arrayList.size(); i++) {
Integer[] tempIntegers = arrayList.get(i);
System.out.println(tempIntegers[0] + " " + tempIntegers[1] + " " + tempIntegers[2]);
}
return ;
}
if(!isfouchenggong) {
for (int i = 0; i < rongqis.length; i++) {
for (int j = 0; j < rongqis.length; j++) {
if(i != j && !isfouchenggong) {
rongqi iRongqi = new rongqi(rongqis[i].rongliang, rongqis[i].cunliang);
rongqi jRongqi = new rongqi(rongqis[j].rongliang, rongqis[j].cunliang);
rongqis[i].daoru(rongqis[j]);
Integer[] list = new Integer[rongqishuliang];
for (int k = 0; k < list.length; k++) {
list[k] = rongqis[k].cunliang;
}
if (nengfoucharu(arrayList, list) && !isfouchenggong) {
arrayList.add(list);
daoyoufanfa(rongqis, arrayList);
if (!isfouchenggong) {
arrayList.remove(list);
}
}
rongqis[i] = iRongqi;
rongqis[j] = jRongqi;
}
}
}
}
}
}
class rongqi{
int rongliang;
int cunliang;
public rongqi(int rongliang, int cunliang) {
this.rongliang = rongliang;
this.cunliang = cunliang;
}
public void daoru(rongqi beidaoru) {
int yuliang = beidaoru.rongliang - beidaoru.cunliang;
if (this.cunliang <= yuliang) {
beidaoru.cunliang = beidaoru.cunliang + this.cunliang;
this.cunliang = 0;
}else {
this.cunliang = this.cunliang - yuliang;
beidaoru.cunliang = beidaoru.rongliang;
}
}
}
// 12 8 5 12 0 0 6