#include <bits/stdc++.h>
using namespace std;
int powe(int n, int m) {
  if (m == 0) return 1;
  int t = powe(n, m / 2);
  if (m % 2 == 0) return (t * t);
  return (((t * t)) * n);
}
long long mpowe(long long n, long long m) {
  if (m == 0) return 1;
  long long t = powe(n, m / 2);
  t %= 1000000007;
  if (m % 2 == 0) return (t * t) % 1000000007;
  return (((t * t) % 1000000007) * n) % 1000000007;
}
long long logtwo(long long n) {
  if (n == 1) return 0;
  return logtwo(n / 2) + 1;
}
void ceilsearch(long long ar[], long long low, long long high, long long x,
                long long &y) {
  long long mid = (low + high) / 2;
  if (low > high) return;
  if (ar[mid] >= x) {
    y = mid;
    ceilsearch(ar, low, mid - 1, x, y);
  } else {
    ceilsearch(ar, mid + 1, high, x, y);
  }
}
bool isSubSequence(string str1, string str2, int m, int n) {
  if (m == 0) return true;
  if (n == 0) return false;
  if (str1[m - 1] == str2[n - 1])
    return isSubSequence(str1, str2, m - 1, n - 1);
  return isSubSequence(str1, str2, m, n - 1);
}
int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  int ls = s.size();
  int lt = t.size();
  if (ls < lt)
    cout << "need tree"
         << "\n";
  else if (ls == lt) {
    vector<char> v1(ls);
    for (int i = 0; i < ls; i++) v1[i] = s[i];
    vector<char> v2(lt);
    for (int i = 0; i < lt; i++) v2[i] = t[i];
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    int flag = 0;
    for (int i = 0; i < ls; i++) {
      if (v1[i] != v2[i]) {
        cout << "need tree"
             << "\n";
        flag = 1;
        break;
      }
    }
    if (!flag)
      cout << "array"
           << "\n";
  } else {
    if (isSubSequence(t, s, lt, ls))
      cout << "automaton"
           << "\n";
    else {
      int f = 0;
      vector<int> pos(lt);
      size_t fo = s.find(t[0]);
      if (fo != string::npos) {
        pos[0] = fo;
      } else {
        cout << "need tree"
             << "\n";
        f = 1;
      }
      if (!f) {
        for (int i = 1; i < lt; i++) {
          int x = -1;
          for (int j = 0; j < i; j++) {
            if (t[j] == t[i]) x = j;
          }
          if (x == -1) {
            char c = t[i];
            size_t u = s.find(c);
            if (u != string::npos)
              pos[i] = u;
            else {
              cout << "need tree"
                   << "\n";
              f = 1;
            }
          } else {
            char c = t[i];
            size_t u = s.find(c, pos[x] + 1);
            if (u != string::npos)
              pos[i] = u;
            else {
              cout << "need tree"
                   << "\n";
              f = 1;
            }
          }
          if (f) break;
        }
        if (!f) {
          vector<int> slocs(lt);
          for (int i = 0; i < lt; i++) slocs[i] = pos[i];
          sort(slocs.begin(), slocs.end());
          for (int i = 0; i < lt; i++) {
            if (slocs[i] != pos[i]) {
              cout << "both"
                   << "\n";
              f = 1;
              break;
            }
          }
          if (!f)
            cout << "automaton"
                 << "\n";
        }
      }
    }
  }
  return 0;
}
