#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7;
const long long NN = 1073741824;
void Input() {
  freopen("in.txt", "r", stdin);
  ;
  freopen("out.txt", "w", stdout);
  ;
}
string a, b;
map<char, long long> mp, np;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> a >> b;
  if (a.find(b) < 200) {
    cout << "automaton"
         << "\n";
    return 0;
  }
  long long n = a.size(), j = 0;
  if (n < b.size()) {
    cout << "need tree"
         << "\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == b[j]) j++;
    mp[a[i]]++;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  n = b.size();
  if (j == n) {
    cout << "automaton"
         << "\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (!mp[b[i]]) {
      cout << "need tree"
           << "\n";
      return 0;
    }
    np[b[i]]++;
  }
  if (a == b)
    cout << "array";
  else {
    for (int i = 0; i < n; i++) {
      if (np[b[i]] > mp[b[i]]) {
        cout << "need tree"
             << "\n";
        return 0;
      }
    }
    cout << "both";
  }
}
