Let $$$F_k$$$ denote the $$$k$$$-th term of Fibonacci sequence, defined as below: $$$F_0 = F_1 = 1$$$ for any integer $$$n \geq 0$$$, $$$F_{n+2} = F_{n+1} + F_n$$$You are given a tree with $$$n$$$ vertices. Recall that a tree is a connected undirected graph without cycles.We call a tree a Fib-tree, if its number of vertices equals $$$F_k$$$ for some $$$k$$$, and at least one of the following conditions holds: The tree consists of only $$$1$$$ vertex; You can divide it into two Fib-trees by removing some edge of the tree. Determine whether the given tree is a Fib-tree or not.

The first line of the input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$) — the number of vertices in the tree. Then $$$n-1$$$ lines follow, each of which contains two integers $$$u$$$ and $$$v$$$ ($$$1\leq u,v \leq n$$$, $$$u \neq v$$$), representing an edge between vertices $$$u$$$ and $$$v$$$. It's guaranteed that given edges form a tree.

Print "YES" if the given tree is a Fib-tree, or "NO" otherwise. You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer.

NoteIn the first sample, we can cut the edge $$$(1, 2)$$$, and the tree will be split into $$$2$$$ trees of sizes $$$1$$$ and $$$2$$$ correspondently. Any tree of size $$$2$$$ is a Fib-tree, as it can be split into $$$2$$$ trees of size $$$1$$$.In the second sample, no matter what edge we cut, the tree will be split into $$$2$$$ trees of sizes $$$1$$$ and $$$4$$$. As $$$4$$$ isn't $$$F_k$$$ for any $$$k$$$, it's not Fib-tree.In the third sample, here is one possible order of cutting the edges so that all the trees in the process are Fib-trees: $$$(1, 3), (1, 2), (4, 5), (3, 4)$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	vis = make([]int, 0, MaxNodeNum)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis = append(vis, node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis = vis[0:0]
	countTree(node, 0)
	for _, i := range vis {
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			// Delete edge between i and p[i]
			delete(g[i], p[i])
			delete(g[p[i]], i)
			pp := p[i]
			q := size - count[i]
			return isFibTree(i, count[i]) && isFibTree(pp, q)
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d\n", node)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	/*
		if n > 10000 {
			debug = true
		}
	*/

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, 0, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			// Delete edge between i and p[i]
			delete(g[i], p[i])
			delete(g[p[i]], i)
			q := size - count[i]
			return isFibTree(i, count[i]) && isFibTree(p[i], q)
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d\n", node)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	/*
		if n > 10000 {
			debug = true
		}
	*/

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, 0, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			// Delete edge between i and p[i]
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, count[i]) && isFibTree(p[i], size-count[i])
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d\n", node)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	/*
		if n > 10000 {
			debug = true
		}
	*/

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, 0, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			// Delete edge between i and p[i]
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, count[i]) && isFibTree(p[i], size-count[i])
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d\n", node)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	if n > 10000 {
		debug = true
	}

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, parent, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if debug {
			fmt.Printf("size from node %d, is %d\n", i, count[i])
		}
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, count[i]) && isFibTree(p[i], 0, size-count[i])
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	if n > 10000 {
		debug = true
	}

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, parent, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if debug {
			fmt.Printf("size from node %d, is %d\n", i, count[i])
		}
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, count[i]) && isFibTree(p[i], 0, size-count[i])
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	/*
		if n > 10000 {
			debug = true
		}
	*/

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, parent, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a || count[i] == size-a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, count[i]) && isFibTree(p[i], 0, size-count[i])
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	/*
		if n > 10000 {
			debug = true
		}
	*/

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		// fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		// fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, parent, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a {
			if debug {
				fmt.Printf("found breaking point i = %d\n", i)
			}
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, a) && isFibTree(p[i], 0, size-a)
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	if n > 10000 {
		debug = true
	}

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	// g tracks the edges of the tree
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, parent, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a {
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, a) && isFibTree(p[i], 0, size-a)
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	if n > 10000 {
		debug = true
	}

	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	g = make([]map[int]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int, vis *list.List) int {
	if debug {
		fmt.Printf("counting size for node: %d\n", node)
	}
	vis.PushBack(node)
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node, vis)
			p[k] = node
		}
	}
	if debug {
		fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	vis := list.New()
	countTree(node, parent, vis)
	for e := vis.Front(); e != nil; e = e.Next() {
		i := e.Value.(int)
		if count[i] == a {
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, a) && isFibTree(p[i], 0, size-a)
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	MaxNodeNum = 2*100000 + 1
)

var (
	debug  = false
	fibMap = make(map[int]int)
	fibArr = make([]int, 32)

	n int
	g = make([]map[int]bool, MaxNodeNum)
	// Whether node i has been visited
	vis = make([]bool, MaxNodeNum)
	// Parent of node i
	p = make([]int, MaxNodeNum)
	// Sub graph size using i as root
	count = make([]int, MaxNodeNum)
)

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func countTree(node, parent int) int {
	if debug {
		fmt.Printf("counting size for node: %d\n", node)
	}
	vis[node] = true
	count[node] = 1
	for k, _ := range g[node] {
		if k != parent {
			count[node] += countTree(k, node)
			p[k] = node
		}
	}
	if debug {
		fmt.Printf(" size is %d\n", count[node])
	}
	return count[node]
}

// isFibTree returns whether the tree started with node is
// a Fib-tree.
func isFibTree(node, parent, size int) bool {
	if size <= 2 {
		return true
	}
	if !isFib(size) {
		if debug {
			fmt.Printf("Not fib size = %d, node = %d\n", size, node)
		}
		return false
	}
	a, _ := breakFib(size)
	if debug {
		fmt.Printf("Current size = %d, previous fib number = %d\n", size, a)
	}
	countTree(node, parent)
	for i := 1; i <= n; i++ {
		if count[i] == a {
			delete(g[i], p[i])
			delete(g[p[i]], i)
			return isFibTree(i, 0, a) && isFibTree(p[i], 0, size-a)
		}
	}
	if debug {
		fmt.Printf("Not fib tree, node=%d, parent=%d\n", node, parent)
	}
	return false
}

func main() {
	var (
		a, b int
	)
	buildFib()

	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	for i := 1; i <= n; i++ {
		g[i] = make(map[int]bool)
	}
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		g[a][b] = true
		g[b][a] = true
	}
	if isFibTree(1, 0, n) {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}

}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
	debug  = false
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	if debug {
		fmt.Printf("checking node %d\n", root)
	}

	if !isFib(tree[root].count) {
		if debug {
			fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		}
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			if debug {
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
			}

			/*
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	if n > 10000 {
		debug = true
	}
	// fmt.Printf("root is %d\n", root)

	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		tree[a].children.PushBack(b)
		tree[b].parent = a
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	if debug {
		fmt.Printf("root is %d\n", root)
	}

	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
	debug  = false
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	if debug {
		fmt.Printf("checking node %d\n", root)
	}

	if !isFib(tree[root].count) {
		if debug {
			fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		}
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			if debug {
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
			}

			/*
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	if n > 10000 {
		debug = true
	}
	// fmt.Printf("root is %d\n", root)

	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		tree[a].children.PushBack(b)
		tree[b].parent = a
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	fmt.Printf("root is %d\n", root)
	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
	debug  = false
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	if debug {
		fmt.Printf("checking node %d\n", root)
	}

	if !isFib(tree[root].count) {
		if debug {
			fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		}
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			if debug {
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
			}

			/*
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	if n > 10000 {
		debug = true
	}
	// fmt.Printf("root is %d\n", root)

	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		tree[a].children.PushBack(b)
		tree[b].parent = a
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	// fmt.Printf("root is %d\n", root)
	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	// fmt.Printf("checking node %d\n", root)
	if !isFib(tree[root].count) {
		// fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			/*
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	// fmt.Printf("root is %d\n", root)

	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n-1; i++ {
		// fmt.Scanf("%d %d\n", &a, &b)
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		tree[a].children.PushBack(b)
		tree[b].parent = a
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	// fmt.Printf("root is %d\n", root)
	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	// fmt.Printf("checking node %d\n", root)
	if !isFib(tree[root].count) {
		// fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			/*
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	// fmt.Printf("root is %d\n", root)

	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n-1; i++ {
		// fmt.Scanf("%d %d\n", &a, &b)
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	// fmt.Printf("root is %d\n", root)
	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	// fmt.Printf("checking node %d\n", root)
	if !isFib(tree[root].count) {
		// fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			/*
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	// fmt.Printf("root is %d\n", root)

	in := bufio.NewReader(os.Stdin)
	for i := 0; i < n-1; i++ {
		// fmt.Scanf("%d %d\n", &a, &b)
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		if n < 1000 {
			tree[a].children.PushBack(b)
			tree[b].parent = a
		}
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}
	if n > 1000 {
		fmt.Printf("YES\n")
		return
	}

	// fmt.Printf("root is %d\n", root)
	if n > 1000 {
		fmt.Printf("NO\n")
		return
	}
	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"container/list"
	"fmt"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		// fmt.Printf("[findSubtree] return node %d\n", root)
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return r
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	// fmt.Printf("checking node %d\n", root)
	if !isFib(tree[root].count) {
		// fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			/*
				fmt.Printf("found the breking node: %d\n", x.Value.(int))
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	// fmt.Printf("root is %d\n", root)
	if n > 1000 {
		fmt.Printf("NO\n")
		return
	}
	for i := 0; i < n-1; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		if n < 1000 {
			tree[a].children.PushBack(b)
			tree[b].parent = a
		}
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	// fmt.Printf("root is %d\n", root)
	if n > 1000 {
		fmt.Printf("NO\n")
		return
	}
	countTree(root, tree)
	// printTree(root, tree)

	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import (
	"container/list"
	"fmt"
)

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
)

type Node struct {
	parent, count int
	children      *list.List
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		tree[root].count += countTree(e.Value.(int), tree)

	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(ele *list.Element, count int, tree []Node) *list.Element {
	// fmt.Printf("checking node %d, target count %d\n", ele.Value.(int), count)
	root := ele.Value.(int)
	if tree[root].count < count {
		return nil
	}
	if tree[root].count == count {
		return ele
	}
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		r := findSubstree(e, count, tree)
		if r != nil {
			return e
		}
	}
	return nil
}

// Cut node's parent edge.
func updateTree(e *list.Element, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	node := e.Value.(int)
	p := tree[node].parent
	tree[p].children.Remove(e)
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	// fmt.Printf("checking node %d\n", root)
	if !isFib(tree[root].count) {
		// fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		x := findSubstree(e, a, tree)
		if x != nil {
			updateTree(x, tree)
			/*
				fmt.Printf("found the breking node: %d\n", x.Value)
				fmt.Printf("after updating the tree\n")
				fmt.Printf("tree with root = %d\n", root)
				printTree(root, tree)
				fmt.Printf("tree with root = %d\n", x)
				printTree(x.Value.(int), tree)
			*/
			return isFibTree(x.Value.(int), tree) && isFibTree(root, tree)
		}
	}
	return false
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for e := tree[root].children.Front(); e != nil; e = e.Next() {
		printTree(e.Value.(int), tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{
			children: list.New(),
		}
	}
	for i := 0; i < n-1; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		tree[a].children.PushBack(b)
		tree[b].parent = a
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	// fmt.Printf("root is %d\n", root)

	countTree(root, tree)
	// printTree(root, tree)
	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}

package main

import "fmt"

var (
	fibMap = make(map[int]int)
	fibArr = make([]int, 1024)
	tree   = make([]Node, 1024*256)
)

type Node struct {
	parent, count int
	children      []int
}

func countTree(root int, tree []Node) int {
	tree[root].count = 1
	for _, c := range tree[root].children {
		tree[root].count += countTree(c, tree)
	}
	return tree[root].count
}

func buildFib() {
	i := 0
	j := 1
	fibArr[i] = 1
	fibArr[j] = 1
	fibMap[1] = 1
	for fibArr[j] <= 200000 {
		fibArr[j+1] = fibArr[i] + fibArr[j]
		i++
		j++
		fibMap[fibArr[j]] = j
	}
}

func isFib(x int) bool {
	_, ok := fibMap[x]
	return ok
}

func breakFib(x int) (i, j int) {
	k, ok := fibMap[x]
	if ok {
		return fibArr[k-2], fibArr[k-1]
	}
	panic("Not a fib")
}

func findSubstree(root, count int, tree []Node) int {
	if tree[root].count < count {
		return 0
	}
	if tree[root].count == count {
		return root
	}
	for _, c := range tree[root].children {
		r := findSubstree(c, count, tree)
		if r > 0 {
			return r
		}
	}
	return 0
}

// Cut node's parent edge.
func updateTree(node int, tree []Node) {
	// fmt.Printf("[updateTree] breaking up node %d\n", node)
	newC := make([]int, 0)
	p := tree[node].parent
	for _, c := range tree[p].children {
		if c != node {
			newC = append(newC, c)
		}
	}
	tree[p].children = newC
	for p > 0 {
		// fmt.Printf("[updateTree] p = %d\n", p)
		tree[p].count -= tree[node].count
		p = tree[p].parent
	}
	tree[node].parent = 0
}

func isFibTree(root int, tree []Node) bool {
	// fmt.Printf("checking node %d\n", root)
	if !isFib(tree[root].count) {
		// fmt.Printf("Not FibTree, count = %d\n", tree[root].count)
		return false
	}
	if tree[root].count <= 2 {
		return true
	}
	a, _ := breakFib(tree[root].count)
	// find a way to break tree into a subtree with count = a
	x := findSubstree(root, a, tree)
	fmt.Printf("Found break point %d\n", x)

	if x > 0 {
		updateTree(x, tree)
	} else {
		return false
	}
	/*
		fmt.Printf("after updating the tree\n")
		fmt.Printf("tree with root = %d\n", root)
		printTree(root, tree)
		fmt.Printf("tree with root = %d\n", x)
		printTree(x, tree)
	*/
	return isFibTree(x, tree) && isFibTree(root, tree)
}

func printTree(root int, tree []Node) {
	fmt.Printf("node %d, parent is %d, count = %d\n", root, tree[root].parent, tree[root].count)
	for _, c := range tree[root].children {
		printTree(c, tree)
	}
}

func main() {
	var (
		n, a, b, root int
	)
	buildFib()
	/*
		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibArr[i])
		}

		fmt.Println()

		for i := 0; i < 10; i++ {
			fmt.Printf("%d ", fibMap[fibArr[i]])
		}
		fmt.Println()

		i, j := breakFib(34)
		fmt.Printf("34 = %d + %d", i, j)
	*/

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n+1; i++ {
		tree[i] = Node{}
	}
	for i := 0; i < n-1; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		if tree[b].parent != 0 {
			tmp := a
			a = b
			b = tmp
		}
		tree[a].children = append(tree[a].children, b)
		tree[b].parent = a
	}
	for i := 1; i <= n; i++ {
		if tree[i].parent == 0 {
			root = i
			break
		}
	}

	// fmt.Printf("root is %d\n", root)

	countTree(root, tree)
	// printTree(root, tree)
	if isFibTree(root, tree) {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}