import java.util.*;
import java.io.*;
public class HelpVasilisaTheWise2 {
    static BufferedReader br;
    static int[] s;
    static ArrayList[] p;
    public static void main(String[] args) {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            init();
            System.out.println(solve());
            br.close();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
    private static void init() throws IOException {
    	s = new int[6];
    	int count = 0;
    	for(int i = 0; i < 3; i++) {
    		StringTokenizer st = new StringTokenizer(br.readLine());
    		s[count++] = Integer.parseInt(st.nextToken());
    		s[count++] = Integer.parseInt(st.nextToken());
    	}
    	p = new ArrayList[6];
        for(int i = 0; i < 6; i++) {
        	p[i] = new ArrayList<Integer>();
        	for(int j = 1; j <= 9; j++)
        		if(j < s[i] && (double)(j) != (double)(s[i]) / 2 && s[i] - j <= 9)
        			p[i].add(j);
//        	System.out.println(Arrays.toString(p[i].toArray()));
        }
    }
    private static String solve() {
        String res = "";
        int[] slots = new int[4];
        for(int i = 0; i < 4; i++)
        	slots[i] = determine(i);
        res += String.valueOf(slots[0]) + " " + String.valueOf(slots[1]) + "\n" + String.valueOf(slots[2]) + " " + 
        	String.valueOf(slots[3]);
        return res;
    }
    private static int determine(int index) {
    	if(index == 0)
    		return check(0, 2, 4);
    	else if(index == 1)
    		return check(0, 3, 5);
    	else if(index == 2)
    		return check(1, 2, 5);
    	return check(1, 3, 4);
    }
    private static int check(int index1, int index2, int index3) {
    	ArrayList<Integer> l1 = p[index1];
    	ArrayList<Integer> l2 = p[index2];
    	ArrayList<Integer> l3 = p[index3];
    	System.out.println(Arrays.toString(l1.toArray()));
    	System.out.println(Arrays.toString(l2.toArray()));
    	System.out.println(Arrays.toString(l3.toArray()));
    	for(int i = 9; i >= 1; i--) {
    		if(l1.contains(i) && l2.contains(i) && l3.contains(i))
    			return i;
    	}
    	return 0;
    }
}