<>; ($x,$y)=<>=~/\d+/g; $d=$y-$x; print(-1),exit if$d<1; for(<>){ ($x,$y)=/\d+/g; $e=$y-$x; print(-1),exit if$d-$e; } print$d;