var maxCount;
var mats = [];
var matts = [];
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var c = parseInt(input[2], 10);
    var d = parseInt(input[3], 10);

    maxCount = a * b;



    for (var i = 0; i < maxCount; i++) {
        mats.push([0, 1]);
    }

    saiki([], 0);

    var result = matts.find(e => {

        var result1 = true;
        for (var j = 0; j < b; j++) {
            var aaa = e.slice(j * a, (j + 1) * a).reduce((prev, curr) => {
                return prev + curr;
            }, 0)
            aaa = aaa == 2 ? 1 : aaa;
            aaa = aaa == 3 ? 0 : aaa;
            if (aaa != c) {
                result1 = false
            }
        }

        var result2 = true;
        if (result1) {
            for (var k = 0; k < a; k++) {
                var aaa = 0;
                for (var t = 0; t < b; t++) {
                    aaa += e[t * a + k]
                }
                aaa = aaa == 2 ? 1 : aaa;
                aaa = aaa == 3 ? 0 : aaa;
                if (aaa != d) {
                    return false;
                }
            }
        }
        return result1 && result2;        
})
console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function saiki(array, index) {
    if (index == maxCount) {
        matts.push(array);
        return;
    } else {
        mats[index].forEach(e => {
            var newArray = array.slice()
            newArray.push(e);
            saiki(newArray, index + 1)
        })
    }
}




