#!/usr/bin/perl -w

use v5.36;
use strict;
use experimental 'multidimensional';

my $tsc = 1;
my $prev_tsc = 1;
my $x = 1;
my $prev_gen = 0;
while (<>) {
	my ($op, $num) = /^(\w+)(?: (-?\d+))?/;

	$tsc++;
	while ($prev_tsc <= $tsc) {
		# say "$prev_tsc ok" if $x +2 <= $prev_tsc;
		my $off = $prev_tsc % 40;
		print(($x <= $off && $x + 2 >= $off) ? '#' : '.');
		print "\n" if $prev_tsc % 40 == 0;
		$prev_tsc++;
	}
	if ($op eq 'addx') {
		$x += $num;
		$tsc++;
	}
}
print "\n";

