#!/usr/bin/perl

$verts = 0;
$edges = 0;
$tris = 0;
while (<>) {
    if (/^v (.*) (.*) (.*)/) {
        $verts++;
    } elsif (/^f (.*) (.*) (.*)/) {
        $faces++;
        $edges += 3;
    }
}

print "$verts $edges $faces\n";

seek(STDIN,0,0);
while (<>) {
    if (/^v (.*) (.*) (.*)/) {
        print "$1 $2 $3\n";
    }
}

seek(STDIN,0,0);
while (<>) {
    if (/^f ([0-9]+) ([0-9]+) ([0-9]+)/) {
        print "$1 $2\n";
        print "$2 $3\n";
        print "$3 $1\n";
    }
}

for ($count = 0; $count < $faces; $count++) {
    $e1 = 3 * $count + 1;
    $e2 = 3 * $count + 2;
    $e3 = 3 * $count + 3;
    print "$e1 $e2 $e3\n";
}
