#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
void solve() {
  string s, t;
  cin >> s >> t;
  if (s.find(t) != -1)
    cout << "automaton\n";
  else if (s.length() >= t.length()) {
    int l1 = s.length(), l2 = t.length();
    unordered_map<char, int> f1, f2;
    for (int i = 0; i < l1; i++) f1[s[i]]++;
    for (int i = 0; i < l2; i++) f2[t[i]]++;
    for (auto p : f2) {
      if (f1[p.first] < p.second) {
        cout << "need tree\n";
        return;
      }
    }
    if (l1 == l2)
      cout << "array\n";
    else {
      for (int i = 0, j = 0; i < l1; i++) {
        if (j < l2 && s[i] == t[j]) j++;
        if (j == l2) {
          cout << "automaton\n";
          return;
        }
      }
      cout << "both\n";
    }
  } else
    cout << "need tree\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
