#include <bits/stdc++.h>
using namespace std;
inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd<T>(a, b);
}
template <class T>
inline T power(T b, T p) {
  long long ans = 1;
  while (p--) ans *= b;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  map<char, long long> S, T;
  long long i = 0, j = 0;
  cin >> 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 (T[c] > S[c]) return cout << "need tree\n", 0;
  for (; i < s.size() && j < t.size();) {
    if (s[i] == t[j])
      i++, j++;
    else
      i++;
    if (j == t.size()) return cout << "automaton\n", 0;
  }
  cout << "both\n";
}
