#include <bits/stdc++.h>
using namespace std;
bool find(string main, int r, string sub, int n) {
  if (n == 0) return true;
  if (r < 0) return false;
  if (main[r] == sub[n - 1]) {
    return find(main, r - 1, sub, n - 1);
  } else {
    return find(main, r - 1, sub, n);
  }
}
int main() {
  string s;
  string t;
  cin >> s;
  cin >> t;
  map<char, int> mp1;
  map<char, int> mp2;
  if (find(s, s.size() - 1, t, t.size()) == true) {
    cout << "automaton";
    return 0;
  }
  for (int i = 0; i < s.size(); i++) mp1[s[i]]++;
  for (int i = 0; i < t.size(); i++) mp2[t[i]]++;
  int flag = 0;
  map<char, int>::iterator iter1, iter2;
  for (iter1 = mp1.begin(), iter2 = mp2.begin();
       iter1 != mp1.end() && iter2 != mp2.end(); ++iter1, ++iter2) {
    if (iter1->first != iter2->first || iter1->second != iter2->second) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    cout << "array";
    return 0;
  }
  flag = 0;
  for (iter2 = mp2.begin(); iter2 != mp2.end(); ++iter2)
    mp1[iter2->first] -= iter2->second;
  for (iter1 = mp1.begin(); iter1 != mp1.end(); ++iter1)
    if (iter1->second < 0) {
      flag = 1;
      break;
    }
  if (flag == 0) {
    cout << "both";
    return 0;
  }
  cout << "need tree";
  return 0;
}
