#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  map<char, int> S, T;
  for (char c : s) S[c]++;
  for (char c : t) T[c]++;
  if (S == T) return cout << "array\n", 0;
  for (char c : t)
    if (S[c] < T[c]) return cout << "need tree\n", 0;
  int i = 0, j = 0;
  for (; i < s.length() && j < t.length();) {
    if (s[i] == t[j])
      i++, j++;
    else
      i++;
    if (t.length() == j) return cout << "automaton\n", 0;
  }
  cout << "both\n";
}
