#include <bits/stdc++.h>
using namespace std;
int a[26];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  bool automaton = 1, array = 1, both = 1;
  int l1 = s1.length(), l2 = s2.length();
  for (int i = 0; i < l1; i++) a[s1[i] - 'a']++;
  for (int i = 0; i < l2; i++) a[s2[i] - 'a']--;
  for (int i = 0; i < 26; i++) {
    if (a[i] != 0) array = 0;
    if (a[i] < 0) both = 0;
  }
  int pos = 0;
  for (int i = 0; i < l1; i++) {
    if (pos < l2 && s2[pos] == s1[i]) pos++;
  }
  if (pos != l2) automaton = 0;
  if (automaton)
    cout << "automaton";
  else if (array)
    cout << "array";
  else if (both)
    cout << "both";
  else
    cout << "need tree";
  return 0;
}
