#include <bits/stdc++.h>
using namespace std;
string s, t, c;
int l, i;
int main() {
  cin >> s >> t;
  c = s;
  l = t.size();
  for (i = 0; i < l; i++)
    if (i < c.size() && t[i] != c[i]) c.erase(i, 1), i--;
  if (c.find(t) != -1) return cout << "automaton" << endl, 0;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  if (s == t) return cout << "array" << endl, 0;
  for (i = 0; i < l; i++)
    if (i < s.size() && t[i] != s[i]) s.erase(i, 1), i--;
  if (s.find(t) != -1) return cout << "both" << endl, 0;
  cout << "need tree" << endl;
}
