#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define bit(n,k) ((n>>k)&1) //nのk　bit目
#define vec(T) vector<T>
#define vvec(T) vector<vector<T>>
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e9;

//------------------------------------------------


struct Solver{

    void solve(){
        int N;
        cin >> N;
        vec(ll) a(N);
        vec(int) t(N);
        rep(i,N) cin >> a[i] >> t[i];
        int Q;
        cin >> Q;
        vec(ll) x(Q);
        rep(i,Q) cin >> x[i];

        ll s=0;
        ll xmin=-llINF, xmax=llINF;
        rep(i,N){
            if(t[i]==1) s+=a[i];
            else if(t[i]==2) chmax(xmin, a[i]-s);
            else if(t[i]==3) chmin(xmax, a[i]-s);
        }

        ll y=xmin;
        rep(i,N){
            if(t[i]==1) y+=a[i];
            else if(t[i]==2) chmax(y,a[i]);
            else if(t[i]==3) chmin(y,a[i]);                
        }
        ll d = y-xmin;

        if(xmin>xmax){
            rep(i,Q) cout << y << endl;
        }else{
            rep(i,Q){
                if(x[i]<xmin) cout << y << endl;
                else if(x[i]>xmax) cout << d + xmax << endl;
                else cout << d+x[i] << endl;
            }
        }
    }
};


int main(){
    int testcasenum=1;
    //cin >> testcasenum;
    rep1(ti,testcasenum){
        Solver solver;
        solver.solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int mod = 1e9;

const int INF = 1001001001;

int h, w;
int a[2005][2005];

bool visited[2005][2005];
int memo[2005][2005];

int f(int i, int j)
{
  if (i == h - 1 && j == w - 1)
    return 0;
  if (visited[i][j])
    return memo[i][j];
  visited[i][j] = true;
  int res = -INF;
  if (j + 1 < w)
    res = max(res, a[i][j + 1] - f(i, j + 1));
  if (i + 1 < h)
    res = max(res, a[i + 1][j] - f(i + 1, j));
  return memo[i][j] = res;
}

int main()
{
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++)
  {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      a[i][j] = s[i][j] == '+' ? 1 : -1;
    }
  }

  int score = f(0, 0);
  if (score == 0)
    cout << "Draw" << endl;
  if (score < 0)
    cout << "Aoki" << endl;
  if (score > 0)
    cout << "Takahashi" << endl;
  return 0;
}