#!/usr/bin/perl

use v5.30;
use strict;

my $in = 368078;

my ($x, $y) = (1, 0);
my $r = 1;
$; = ',';
my %map = ("0,0" => 1);
sub set {
	my ($x, $y) = @_;
	my $sum = 0;
	for my $dx (-1 .. 1) {
	for my $dy (-1 .. 1) {
		$sum += $map{$x+$dx,$y+$dy} if defined
			$map{$x+$dx,$y+$dy};
	} }
	$map{$x,$y} = $sum;
		
	say "$x, $y = ", $sum;
	exit 0 if $sum > $in;
}

while (1) {
	for my $i (0 .. 2*$r-1) {
		set($x, $y-$i);
	}
	$y -= 2*$r-1;
	for my $i (1 .. 2*$r) {
		set($x-$i, $y);
	}
	$x -= 2*$r;
	for my $i (1 .. 2*$r) {
		set($x, $y+$i);
	}
	$y += 2*$r;
	for my $i (1 .. 2*$r) {
		set($x+$i, $y);
	}
	$x += 2*$r+1;
	$r++;
}
