#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
bool issubsequence(string s, string t, long long int x, long long int y) {
  long long int j = 0;
  for (long long int i = 0; i < x && j < y; i++)
    if (t[j] == s[i]) j++;
  return (j == y);
}
void solve() {
  string s, t;
  cin >> s >> t;
  long long int x = s.length(), y = t.length(), a[26] = {}, b[26] = {};
  for (long long int(i) = 0; (i) < (x); (i)++) a[(s[i] - 'a')]++;
  for (long long int(i) = 0; (i) < (y); (i)++) b[(t[i] - 'a')]++;
  if (x == y) {
    bool ok = true;
    for (long long int(i) = 0; (i) < (26); (i)++) {
      if (a[i] != b[i]) {
        ok = false;
        break;
      }
    }
    if (ok)
      cout << "array\n";
    else
      cout << "need tree\n";
  } else if (x > y) {
    if (issubsequence(s, t, x, y))
      cout << "automaton\n";
    else {
      bool flag = true;
      for (long long int(i) = 0; (i) < (26); (i)++) {
        42;
        if (b[i] > 0 && b[i] > a[i]) {
          flag = false;
          break;
        }
      }
      if (flag)
        cout << "both\n";
      else
        cout << "need tree\n";
    }
  } else
    cout << "need tree\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
