01 Game

F. 01 Game

Problem

Alica and Bob are playing a game.

Initially they have a binary string s s s consisting of only characters 0 and 1.

Alice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. During each move, the current player must choose two different adjacent characters of string s s s and delete them. For example, if s = 1011001 s = 1011001 s=1011001 then the following moves are possible:

  1. delete s 1 s_1 s1 and s 2 s_2 s2: 10 11001 → 11001 \textbf{10}11001 \rightarrow 11001 101100111001;
  2. delete s 2 s_2 s2 and s 3 s_3 s3: 1 01 1001 → 11001 1\textbf{01}1001 \rightarrow 11001 101100111001;
  3. delete s 4 s_4 s4 and s 5 s_5 s5: 101 10 01 → 10101 101\textbf{10}01 \rightarrow 10101 101100110101;
  4. delete s 6 s_6 s6 and s 7 s_7 s7: 10110 01 → 10110 10110\textbf{01} \rightarrow 10110 101100110110.

If a player can’t make any move, they lose. Both players play optimally. You have to determine if Alice can win.

Input

First line contains one integer t t t ( 1 ≤ t ≤ 1000 1 \le t \le 1000 1t1000) — the number of test cases.

Only line of each test case contains one string s s s ( 1 ≤ ∣ s ∣ ≤ 100 1 \le |s| \le 100 1s100), consisting of only characters 0 and 1.

Output

For each test case print answer in the single line.

If Alice can win print DA (YES in Russian) in any register. Otherwise print NET (NO in Russian) in any register.

Example

Input
3
01
1111
0011
Output
DA
NET
NET

Note

In the first test case after Alice’s move string s s s become empty and Bob can not make any move.

In the second test case Alice can not make any move initially.

In the third test case after Alice’s move string s s s turn into 01 01 01. Then, after Bob’s move string s s s become empty and Alice can not make any move.

Code

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//堆/优先队列
// #include <queue>//队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

void solve()
{
    string s;
    cin>>s;

    ll x=0;
    for(auto &t:s)
    {
        if(t=='0') x++;
    }

    ll mn=min(x,ll(s.size()-x));
    if(mn&1) cout<<"DA"<<endl;
    else cout<<"NET"<<endl;
}

int main()
{
    ll t;
    cin>>t;
    while(t--) solve();
    
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值