#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using ll = long long;
template <typename T>
inline T abs(T a) {
  return ((a < 0) ? -a : a);
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
string s;
string t;
bool isSubSequence(int m, int n) {
  bool ok = false;
  for (int i = 0, j = 0; i < n; ++i) {
    if (j < m && s[i] == t[j]) ++j;
    if (j == m) ok = true;
  }
  return ok;
}
void solve() {
  cin >> s >> t;
  int m = ((int)(t).size());
  int n = ((int)(s).size());
  if (isSubSequence(m, n)) {
    cout << "automaton";
    return;
  }
  vi cnt(26, 0);
  bool isarray = true, isboth = true;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cnt[s[i] - 'a']++;
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - 2 * ((0) > (m)))
    cnt[t[i] - 'a']--;
  for (__typeof(26) i = (0) - ((0) > (26)); i != (26) - ((0) > (26));
       i += 1 - 2 * ((0) > (26))) {
    isarray &= (cnt[i] == 0);
    isboth &= (cnt[i] >= 0);
  }
  if (isarray)
    cout << "array";
  else if (isboth)
    cout << "both";
  else
    cout << "need tree";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
