#!/usr/bin/perl -w

use strict;
use v5.30;

my @ints = ([ 0, (1 << 32)-1 ]);
INT:
while (<>) {
	chomp;
	say join(' ', map { $_->[0] . '-' . $_->[1] } @ints);
	my ($lo, $hi) = split /-/;
	say "blacklisting $lo-$hi";
	my $i = 0;
	while ($i < @ints) {
		my $int = $ints[$i];
		if ($int->[0] < $lo && $int->[1] > $hi) {
			splice @ints, $i, 1, [ $int->[0], $lo-1 ], [ $hi+1, $int->[1] ];
			next INT;
		} elsif ($int->[0] < $lo && $int->[1] >= $lo && $int->[1] <= $hi) {
			splice @ints, $i, 1, [ $int->[0], $lo-1 ];
			$i++;
		} elsif ($int->[0] >= $lo && $int->[1] <= $hi) {
			splice @ints, $i, 1;
		} elsif ($int->[0] >= $lo && $int->[0] <= $hi && $int->[1] > $hi) {
			splice @ints, $i, 1, [ $hi+1, $int->[1] ];
			next INT;
		} elsif ($int->[0] > $hi) {
			next INT;
		} else {
			$i++;
		}
	}
}

say $ints[0]->[0];
