Daniel is tired of looking for a job, so he decided to visit his friend Stjepan. Surprisingly, when he entered Stjepan's home, he came across a tree with nodes denoted with numbers from to . The node number contains a coin.
Stjepan told him: "Put this blindfold on and we'll play!" Daniel gave him a strange look, but decided to do it. Stjepan then told him the rules of the game:
- Daniel picks a node and marks it
- Stjepan moves the coin to an unmarked node adjacent to the one where the coin is currently in
- Stjepan marks the node which he moved the coin from
These three steps repeat until Stjepan can't make a move anymore. Given the fact that he is blindfolded, Daniel doesn't exactly know what node contains the coin in any given moment of the game. However, he does know the outline of the tree and where the coin was at the beginning of the game.
Daniel just realized that he hasn't applied to a single job for the past two hours, and wants to quickly finish playing the game. Now he wants to know if he can play in a way that, no matter what moves Stjepan makes, the game ends in at most moves. In other words, so that Stjepan moves the coin less than times.
Help Daniel and determine whether he can finish the game on time and go back to sending his résumé to companies he's never heard of.
Input Specification
The first line of input contains two integers, and .
Each of the following lines contains two integers and that denote that an undirected link exists between nodes labeled with and .
It is guaranteed that the given graph will be a tree.
Output Specification
The first and only line of output must contain the word DA
(Croatian for yes), if Daniel can ensure that the game ends in at most moves, and NE
(Croatian for no) if he can't.
Sample Input 1
6 2
1 2
2 3
3 4
1 5
5 6
Sample Output 1
DA
Sample Input 2
3 1
1 2
1 3
Sample Output 2
NE
Explanation for Sample Output 2
Daniel can mark any node. If he marks node or , Stjepan can move the coin to node , and if he marks node , Stjepan can move the coin to node .
Sample Input 3
8 2
1 2
2 3
2 4
5 6
6 8
1 5
7 1
Sample Output 3
DA
Explanation for Sample Output 3
In his first move, Daniel can mark node , and in the second move mark node . Wherever Stjepan moves the coin in his first move, he won't be able to make a second move.
Comments