#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>T dup(T x, T y){return (x+y-1)/y;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
int keta(ll n) { int ret = 0; while (n>0) { n/=10; ret++; } return ret; }

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) { cerr << head; dump(); }
template <typename Head, typename... Tail> void dump(Head &&head, Tail &&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do { cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

void solve()
{
  int n; cin>>n;
  ll mi = -LINF;
  ll ma = LINF;
  ll fl = 0;
  rep(i, n) {
    ll a,t; cin>>a>>t;
    if (t == 1) {
      mi += a;
      ma += a;
      fl += a;
    }
    if (t == 2) {
      maxs(mi, a);
      maxs(ma, mi);
    }
    if (t == 3) {
      mins(ma, a);
      mins(mi, ma);
    }
  }
  mi -= fl;
  ma -= fl;
  int q; cin>>q;
  vector<ll> x(q); cin>>x;
  rep(i, q) {
    ll v = x[i];
    mins(v, ma);
    maxs(v, mi);
    cout << v+fl << "\n";
  }

}

int main()
{
  int t;
  t = 1;
  // cin>>t;
  while (t--) solve();

  return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll H, W;
string A[2005];

bool vv[2005][2005];
pair<ll, ll> memo[2005][2005];

//ここに飛んできたやつを先手とする
//先手が取れる点数, 後て
pair<ll, ll> dfs(ll y, ll x) {
	if(vv[y][x]) return memo[y][x];
	if(y == H - 1 && x == W-1) {
		if(y == 0 && x == 0) {
			return make_pair(0, 0);
		} else if(A[y][x] == '+') {
			return make_pair(1, 0);
		} else {
			return make_pair(-1, 0);
		}
	}
	pair<ll, ll> ret;
	if(y == H-1) {
		auto tmp = dfs(y, x+1);
		ret = make_pair(tmp.second, tmp.first);
	} else if(x == W-1) {
		auto tmp = dfs(y+1, x);
		ret = make_pair(tmp.second, tmp.first);
	} else {
		auto tmp0 = dfs(y, x+1);
		auto tmp1 = dfs(y+1, x);
		if(tmp0.first - tmp0.second> tmp1.first - tmp1.second) {
			ret = make_pair(tmp0.second, tmp0.first);
		} else {
			ret = make_pair(tmp1.second, tmp1.first);
		}
	}


	if(y != 0 || x != 0) {
		if(A[y][x] == '+') {
			ret.first++;
		} else {
			ret.first--;
		}
	}
	vv[y][x] = true;
	memo[y][x] = ret;
	return ret;
}


int main(){
	cin >> H >> W;
	rep(i, H) cin >> A[i];
	auto item = dfs(0, 0);
	if(item.first == item.second) {
		cout << "Draw" << endl;
	} else if(item.first > item.second) {
		cout << "Aoki" << endl;
	} else {
		cout << "Takahashi" << endl;
	}
}
