P7955 [COCI 2014/2015 #6] NIKO
Background
In 2018, in Russia, the 21st World Cup.
Description
For convenience, let $\tt O$ represent a defensive player, $\tt V$ represent a midfielder, and $\tt N$ represent an attacking player.
The coach has several formation plans $O-V-N$, where $O,V,N$ are the counts of $\tt O,V,N$ respectively. Of course, it must hold that $O+V+N=10$.
Now, each of the $m$ players can play some of the roles among $\tt O,V,N$. The coach wants to know whether each of his formation plans can be achieved.
Input Format
The first line contains an integer $n$, indicating the number of the coach's plans.
The next $n$ lines each contain three integers $O_i,V_i,N_i$, describing each plan.
The next line contains an integer $m$, indicating the number of players.
The next $m$ lines describe the roles that each player can play.
Output Format
Output $n$ lines in total.
- If the $i$-th plan can be satisfied, output `DA` on the $i$-th line.
- Otherwise, output `NE`.
Explanation/Hint
#### Explanation for Sample 1
Obviously, the coach can only use 10-0-0.
#### Explanation for Sample 2
- For 4-4-2, players $1,2,9,10$ can be assigned as $\tt O$, players $4,5,6,7$ can be assigned as $\tt V$, and players $3,8$ can be assigned as $\tt N$.
- For 3-5-2, players $4,9,10$ can be assigned as $\tt O$, players $1,2,5,6$ can be assigned as $\tt V$, and players $3,8$ can be assigned as $\tt N$.
- For 4-3-3, it is impossible, because only $2$ players can be $\tt N$.
#### Constraints
For $100\%$ of the testdata, $1\le n\le 10$, $10\le m\le 22$.
#### Notes
According to the original configuration, the full score is 80 points.
Translated from **[COCI 2014-2015](https://hsin.hr/coci/archive/2014_2015/)** [Contest #6](https://hsin.hr/coci/archive/2014_2015/contest6_tasks.pdf) Task B _**NIKO**_.
Translated by ChatGPT 5