import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static int[][] m;

	public static boolean tryAll(int n) {
		String nn = n+"";
		int a = nn.charAt(0) - '0', b = nn.charAt(1) - '0', c = nn.charAt(2) - '0', d = nn
				.charAt(3) - '0';
		if(a+b==m[0][0] && c+d==m[0][1] && c+a==m[1][0] && b+d==m[1][1] && a+d==m[2][0] && c+b==m[2][1] && a!=b && a!=c && a!=d && b!=c && b!=d && c!=d)
			return true;
		return false;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		while ((line = in.readLine()) != null && line.length() != 0) {
			m = new int[3][2];
			m[0] = retInts(line);
			for (int i = 1; i < m.length; i++)
				m[i] = retInts(in.readLine());
			boolean ans = false;
			for (int i = 1234; i < 10000; i++) {
				if(tryAll(i)){
					ans = true;
					String nn = i+"";
					out.append(nn.charAt(0)+" "+nn.charAt(1)+"\n");
					out.append(nn.charAt(2)+" "+nn.charAt(3)+"\n");
				}
			}
			if(!ans)
				out.append("-1\n");
		}
		System.out.print(out);
	}
	
	public static String f(int n){
		String c = "000";
		return c.substring(0,4-(n+"").length());
	}

	public static int[] retInts(String line) {
		String[] w = line.split(" ");
		int[] nums = new int[w.length];
		for (int i = 0; i < w.length; i++)
			nums[i] = Integer.parseInt(w[i]);
		return nums;
	}
}
