#P6499. [COCI 2016/2017 #2] Burza

[COCI 2016/2017 #2] Burza

Description

Daniel and Stjepan are playing a game on a tree with nn nodes, where the nodes are numbered 1,2,,n1,2,\dots,n. At the start of the game, there is a coin on node 11.

The rules are as follows:

  1. Daniel chooses a node and marks it.
  2. Stjepan marks the node where the coin is currently located.
  3. Stjepan moves the coin to a node that is unmarked and adjacent to the current node.

Repeat the above steps. When Stjepan cannot move the coin, the game ends.

Daniel wants to know whether there exists a fixed strategy such that, no matter how Stjepan plays, the game can be ended within kk rounds. That is, the number of times Stjepan can move the coin is less than kk.

Input Format

The first line contains two integers n,kn,k.

The next n1n-1 lines each contain two integers a,ba,b, indicating that there is an edge between nodes numbered aa and bb.

Output Format

If there exists a strategy that satisfies the condition, output one line DA.

Otherwise, output one line NE.

6 2
1 2
2 3
3 4
1 5
5 6 
DA 
3 1
1 2
1 3 
NE 
8 2
1 2
2 3
2 4
5 6
6 8
1 5
7 1 
DA 

Hint

Sample Explanation

Sample 2 Explanation

  • If Daniel marks node 11, Stjepan can move the coin to node 22 or node 33.
  • If Daniel marks node 22, Stjepan can move the coin to node 33.
  • If Daniel marks node 33, Stjepan can move the coin to node 22.

In all cases, the game cannot be ended within 11 round.

So, there is no strategy that satisfies the condition.

Sample 3 Explanation

  • In the first round, Daniel marks node 22.
  • In the second round, Daniel marks node 66.

No matter how Stjepan plays, he cannot move the coin for the second time.

So, there exists a strategy that satisfies the condition.


Constraints

For 100%100\% of the testdata, 1kn4001\le k\le n\le 400, 1a,bn1\le a,b\le n.


Notes

This problem is translated from COCI2016-2017 CONTEST #2 T6 Burza.

Translated by ChatGPT 5