write(apply(read.table("stdin"),1,function(x)det(diag(x/x)[x,])),1,1)