#!/usr/bin/perl
$line = <>;
$i = 0;
$offset = tell;
while (defined($line = <>)) {
  @fields = split /\s+/, $line;
  if ($fields[1] eq 'u') {
    $conid[$i] = $fields[4];
    $conoff[$i] = $fields[5];
    $condel[$i] = $fields[6];
    $condir[$i] = $fields[7];
    $refid[$i] = $fields[8];
    $refoff[$i] = $fields[9];
    $refdel[$i] = $fields[10];
    $refdir[$i] = $fields[11];
    if ($i > 0) {
      if ($conid[$i] eq $conid[$i-1]) {
        $con1 = $conoff[$i-1] + 1;
        $con2 = $con1 + $condel[$i-1] - 1;
        $con3 = $conoff[$i] + 1;
        $con4 = $con3 + $condel[$i] - 1;
        $congap = $con3 - $con2 - 1;
        $ref1 = $refoff[$i-1] + 1;
        $ref2 = $ref1 + $refdir[$i-1]*($refdel[$i-1] - 1);
        $ref3 = $refoff[$i] + 1;
        $ref4 = $ref3 + $refdir[$i]*($refdel[$i] - 1);
        $refgap = $refdir[$i]*($ref3 - $ref2) - 1;
        print "$conid[$i] $con1 $con2 $con3 $con4 $condir[$i-1] $condir[$i] ";
        print "$refid[$i] $ref1 $ref2 $ref3 $ref4 $refdir[$i-1] $refdir[$i] ";
        print "$congap $refgap $prev_offset $prev_i\n";
      }
    }
  }
  $prev_offset = $offset;
  $offset = tell;	
  $prev_i = $i;
  $i++;
}
