#!/usr/local/bin/perl5
%ex = ();
%pagenum = ( raw, "", e, "", j, "");
$count_init = 200;
%count = ( e, $count_init, j, $count_init);
while( <> ) {
if (/^(!{0,7})(!*)( *)([ej])(0[0-9]{3})( *.*$)/) {
$ex{'1'} = $1;
$ex{'2'} = $2;
$n = "\n";
$tabs = $3;
$tabs2 = $tabs;
if ( $ex{'1'} ne '' ) {
if ( $ex{'2'} ne '' ) {
$tabs2 = " $tabs";
}
} elsif ( $tabs eq /^\t{0,1}$/ ) {
$n = "";
}
$lang = $4;
$pagenum{raw} = $5;
if ($pagenum{$lang} eq $pagenum{raw}) {
$count{$lang} = $count{$lang} + 10;
} else {
$count{$lang} = $count_init;
}
# $_ = "$ex{'1'}$ex{'2'}$tabs#$lang$pagenum{raw}_$count{$lang} #$n$tabs2$6\n";
$_ = "$ex{'1'}$ex{'2'}$tabs$lang$pagenum{raw}_$n$tabs2$6\n";
$pagenum{$lang} = "$pagenum{raw}";
}
# if /([ej]0[0-9]{3}) /
##$lang # @;
print;
}