#! /usr/bin/perl

my $x = 308;
my $y = 385;
my $done = 0;

while (<>) {
	chomp (my $switch = $_);
	print "DELETE FROM placements WHERE switch=$switch;\n";
	printf "INSERT INTO placements VALUES ( $switch, '(%u,%u,%u,%u)');\n",
		$x, $y, $x + 14, $y + 51;
	$y += 51;
	if ($y > 500) {
		$y = 385;
		$x += 18;
		if ($x > 410 && $done == 0) {
			$x += 13;
			$done = 1;
		}
		if ($x > 570 && $done == 1) {
			$x += 12;
			$done = 2;
		}
	}
}
