← Home
```go
package main

import (
	"fmt"
)

type Position struct {
	x, y int
}

func get_distances(n, m int, start Position) [][]int {
	dist := make([][]int, n+1)
	flat := make([]int, (n+1)*(m+1))
	for i := 0; i < len(flat); i++ {
		flat[i] = -1
	}
	for i := 1; i <= n; i++ {
		dist[i] = flat[i*(m+1) : (i+1)*(m+1)]
	}

	q := make([]Position, 0, n*m)
	q = append(q, start)
	dist[start.x][start.y] = 0

	dx := []int{1, 1, -1, -1, 2, 2, -2, -2}
	dy := []int{2, -2, 2, -2, 1, -1, 1, -1}

	head := 0
	for head < len(q) {
		curr := q[head]
		head++

		for i := 0; i < 8; i++ {
			nx, ny := curr.x+dx[i], curr.y+dy[i]
			if nx >= 1 && nx <= n && ny >= 1 && ny <= m {
				if dist[nx][ny] == -1 {
					dist[nx][ny] = dist[curr.x][curr.y] + 1
					q = append(q, Position{nx, ny})
				}
			}
		}
	}
	return dist
}

func main() {
	var n, m int
	if _, err := fmt.Scan(&n, &m); err != nil {
		return
	}
	var r1, c1, r2, c2 int
	if _, err := fmt.Scan(&r1, &c1, &r2, &c2); err != nil {
		return
	}

	TW := Position{n / 2, m / 2}
	TB := Position{n/2 + 1, m / 2}

	distW := get_distances(n, m, TW)
	distB := get_distances(n, m, TB)

	pW := (r1 + c1) % 2
	pB := (r2 + c2) % 2

	dw := distW[r1][c1]
	db := distB[r2][c2]

	is_white := false
	if pW != pB {
		if dw <= db {
			is_white = true
		} else {
			is_white = false
		}
	} else {
		if db <= dw {
			is_white = false
		} else {
			is_white = true
		}
	}

	if is_white {
		fmt.Println("WHITE")
	} else {
		fmt.Println("BLACK")
	}

	my_pos := Position{r1, c1}
	opp_pos := Position{r2, c2}
	if !is_white {
		my_pos = Position{r2, c2}
		opp_pos = Position{r1, c1}
	}

	have_parity_adv := (is_white && pW != pB) || (!is_white && pW == pB)

	var my_dist [][]int
	if is_white {
		my_dist = distW
	} else {
		my_dist = distB
	}

	dx := []int{1, 1, -1, -1, 2, 2, -2, -2}
	dy := []int{2, -2, 2, -2, 1, -1, 1, -1}

	turn_is_mine := is_white

	for {
		if turn_is_mine {
			var best_m Position
			found_capture := false

			for i := 0; i < 8; i++ {
				nx, ny := my_pos.x+dx[i], my_pos.y+dy[i]
				if nx == opp_pos.x && ny == opp_pos.y {
					best_m = Position{nx, ny}
					found_capture = true
					break
				}
			}

			if !found_capture {
				best_dist := 1000000
				best_dist_opp := -1

				for i := 0; i < 8; i++ {
					nx, ny := my_pos.x+dx[i], my_pos.y+dy[i]
					if nx >= 1 && nx <= n && ny >= 1 && ny <= m {
						is_safe := true
						if !have_parity_adv {
							for j := 0; j < 8; j++ {
								ox, oy := opp_pos.x+dx[j], opp_pos.y+dy[j]
								if nx == ox && ny == oy {
									is_safe = false
									break
								}
							}
						}

						if is_safe {
							d := my_dist[nx][ny]
							dist_opp := (nx-opp_pos.x)*(nx-opp_pos.x) + (ny-opp_pos.y)*(ny-opp_pos.y)
							if d < best_dist {
								best_dist = d
								best_dist_opp = dist_opp
								best_m = Position{nx, ny}
							} else if d == best_dist && dist_opp > best_dist_opp {
								best_dist_opp = dist_opp
								best_m = Position{nx, ny}
							}
						}
					}
				}

				if best_dist == 1000000 {
					for i := 0; i < 8; i++ {
						nx, ny := my_pos.x+dx[i], my_pos.y+dy[i]
						if nx >= 1 && nx <= n && ny >= 1 && ny <= m {
							d := my_dist[nx][ny]
							dist_opp := (nx-opp_pos.x)*(nx-opp_pos.x) + (ny-opp_pos.y)*(ny-opp_pos.y)
							if d < best_dist {
								best_dist = d
								best_dist_opp = dist_opp
								best_m = Position{nx, ny}
							} else if d == best_dist && dist_opp > best_dist_opp {
								best_dist_opp = dist_opp
								best_m = Position{nx, ny}
							}
						}
					}
				}
			}

			my_pos = best_m
			fmt.Println(my_pos.x, my_pos.y)
		} else {
			var r, c int
			if _, err := fmt.Scan(&r, &c); err != nil {
				return
			}
			if r == -1 && c == -1 {
				return
			}
			if r == 0 && c == 0 {
				return
			}
			opp_pos = Position{r, c}
		}
		turn_is_mine = !turn_is_mine
	}
}
```