#include<bits/stdc++.h>
using namespace std;
//#include <atcoder/lazysegtree>
//using namespace atcoder;
//using mint = modint998244353;
//using mint = modint1000000007;
#pragma region template
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define overload4(_1,_2,_3,_4,name,...) name
#define overload3(_1,_2,_3,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i=n;i--;)
#define rrep2(i,n) for(ll i=n;i--;)
#define rrep3(i,a,b) for(ll i=b;i-->(a);)
#define rrep(...) overload3(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cerr << endl;int cnt = 0;for(const auto& v : vv){cerr << cnt << "th : "; view(v); cnt++;} cerr << endl;}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
template<class T, class K>bool chmax(T &a, const K b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class K>bool chmin(T &a, const K b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1001001001;
const ll INF = 1001001001001001001ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll rddiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // -20 / 3 == -7
ll power(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a;} a = a * a; p >>= 1;} return ret;}
ll modpow(ll a, ll p, ll mod){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}
ll rudiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } //  20 / 3 == 7
#pragma endregion
// const double pi = acos(-1);
//const ll mod = 998244353;
const ll mod = 1000000007;

int dp[2001][2001];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int h, w; cin >> h >> w;
    V<string> mp(h);
    rep(i,h) cin >> mp[i];
    rep(i,2001) rep(j,2001) dp[i][j] = -inf;
    dp[h - 1][w - 1] = 0;
    rrep(i,h){
        rrep(j,w){
            if(j - 1 >= 0){
                if(mp[i][j] == '-') chmax(dp[i][j - 1], -dp[i][j] - 1);
                else chmax(dp[i][j - 1], -dp[i][j] + 1);
            }
            if(i - 1 >= 0){
                if(mp[i][j] == '-') chmax(dp[i - 1][j], -dp[i][j] - 1);
                else chmax(dp[i - 1][j], -dp[i][j] + 1);
            }
        }
    }
    if(dp[0][0] == 0) cout << "Draw" << endl;
    else if(dp[0][0] > 0) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;
#define rep(i,n) for (int i = 0; i < (n); i++)
int n,m,a[1100],b[1100];
vector <pair<int,char>> g[1100];
ll dp[1100][1100];
int main(){
    cin >> n >> m;
    rep(i,n)rep(j,n) dp[i][j]=mod;
    rep(i,m){
        char c;
        cin >> a[i] >> b[i] >> c;
        a[i]--;b[i]--;
        g[a[i]].emplace_back(b[i],c);
        g[b[i]].emplace_back(a[i],c);
    }
    queue<P> q;
    dp[0][n-1]=0;
    q.emplace(0,n-1);
    while(!q.empty()){
        int a=q.front().first;
        int b=q.front().second;
        q.pop();
        for(auto e:g[a])for(auto f:g[b]){
            if(e.second == f.second){
                if(dp[e.first][f.first]==mod){
                    dp[e.first][f.first]=dp[a][b]+1;
                    q.emplace(e.first,f.first);
                }
            }
        }
    }
    ll ans=mod;
    rep(i,n)ans=min(ans,dp[i][i]*2);
    rep(i,m)ans=min({ans,dp[a[i]][b[i]]*2+1,dp[b[i]][a[i]]*2+1});
    if(ans==mod)cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}
