#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(const T& x) {
  return x * x;
}
template <class T>
inline string tostr(const T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const int inf = 1999999999;
const double pi = acos(-1.0);
const double eps = 1e-9;
int main(int argc, char* argv[]) {
  clock_t _ = clock();
  cout << fixed << setprecision(15);
  string s, t;
  cin >> s >> t;
  bool automaton = false, array = true;
  int cnt1[26], cnt2[26];
  memset((cnt1), (0), sizeof(cnt1));
  memset((cnt2), (0), sizeof(cnt2));
  for (__typeof((s).begin()) it = (s).begin(), _it = (s).end(); it != _it;
       ++it) {
    cnt1[*it - 'a']++;
  }
  for (__typeof((t).begin()) it = (t).begin(), _it = (t).end(); it != _it;
       ++it) {
    cnt2[*it - 'a']++;
  }
  if (s.size() > t.size()) automaton = true;
  for (int i = 0, _i = (26); i < _i; ++i) {
    if (cnt1[i] < cnt2[i]) {
      automaton = array = false;
      break;
    }
  }
  int i2 = 0;
  for (int i1 = 0, _i1 = (s.size()); i1 < _i1; ++i1) {
    if (s[i1] == t[i2]) i2++;
  }
  if (i2 == t.size()) {
    automaton = true;
    array = false;
  }
  if (automaton && array)
    cout << "both" << ('\n');
  else if (automaton)
    cout << "automaton" << ('\n');
  else if (array)
    cout << "array" << ('\n');
  else
    cout << "need tree" << ('\n');
  return 0;
}
