#! /usr/bin/perl
use strict;
use warnings;

my @alts = ();
while (<>) {
	chomp;
	my @x = split / /;
	push @x, 0;
	push @alts, \@x; 
}

for my $i (0..$#alts) {
	next if ($alts[$i]->[4]);
	for my $j (($i+1)..$#alts) {
		if ($alts[$i]->[2] <= $alts[$j]->[2] && $alts[$i]->[3] >= $alts[$j]->[3]) {
			$alts[$j]->[4] = 1;
		}
	}
}

@alts = sort { $a->[2] <=> $b->[2] } @alts;
for my $i (0..$#alts) {
	next if ($alts[$i]->[4]);
	print join(' ', @{$alts[$i]}), "\n";
}
