#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  int k = 0, flag = 0, count2 = 0, count3 = 0, i;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == t[k]) {
      k++;
    }
  }
  if (k == t.size())
    cout << "automaton";
  else {
    for (i = 0; i < t.size(); i++) {
      int x = count(t.begin(), t.end(), t[i]);
      int y = count(s.begin(), s.end(), t[i]);
      if (y == x) {
        count2++;
      } else if (y < x) {
        cout << "need tree";
        flag = 1;
        break;
      } else if (y > x) {
        count2++;
        count3++;
      }
    }
    if (flag == 0) {
      if (count2 == t.size() and count3 == 0 and t.size() == s.size())
        cout << "array";
      else if (count2 == t.size() and count3 == 0 and t.size() != s.size())
        cout << "both";
      else if (count3 > 0 && count2 == t.size())
        cout << "both";
      else
        cout << "need tree";
    }
  }
  return 0;
}
