#!/usr/bin/perl -w

use strict;

sub neg( $ ) {
  my $str = shift;
  if ($str =~ m/-/) {
    $str =~ s/-/ /;
  } elsif ($str =~ m/\+/) {
    $str =~ s/\+/-/;
  } else {
    $str = "-" . $str;
  }
  $str;
}

while (<>) {
  s/[ \t]+$//;

  if (m/([ \t]*)([A-Z][A-Za-z]* *)\[([- m.0-9\"]*)\]$/) {
    my $pre = $1;
    my $cmd = $2;
    my $arg = $3;

    if ($cmd =~ /^Pin/) {
      my ($x, $y, $r) = split(' ', $arg, 3);
      $x = neg($x);
      print $pre, $cmd, "[ $y $x  $r]\n";
    } elsif ($cmd =~ m/^ElementLine/) {
      my ($x, $y, $X, $Y, $r) = split(' ', $arg, 5);
      $x = neg($x);
      $X = neg($X);
      print $pre, $cmd, "[ $y $x $Y $X       $r]\n";
    } elsif ($cmd =~ m/^ElementArc/) {
      my ($x, $y, $r) = split(' ', $arg, 3);
      $x = neg($x);
      print $pre, $cmd, "[ $y $x  $r]\n";
    } else {
      print;
    }
  } else {
    print;
  }

}

