Spider tree

A spider mom plans to buy a tree (an undirected and connected graph with no cycles) for its progeny. The spider mom has nn kids, and wants a tree with 8n8n vertices that can be divided into nn subtrees with exactly eight vertices each (one subtree for each kid, with one vertex for each of its eight legs), only by removing n1n - 1 edges. Let us call such a tree a spider tree.

Given a tree with 8n8n vertices, is it a spider tree?

Input

Input consists of several cases, each with nn followed by 8n18n - 1 pairs xx yy indicating an edge between xx and yy. Assume 1n1041 \le n \le 10^4, that the given graph is indeed a tree, and that vertices are numbered starting from zero.

Output

For every tree, tell if it is a spider tree or not.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:18:51.550Z

© Jutge.org, 2006–2026.
https://jutge.org