#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  string temp1 = s1, temp2 = s2;
  bool flag = false;
  for (int i = 0; i < s2.size(); i++) {
    if (temp1.find(s2[i]) != string::npos)
      temp1 = string(temp1.begin() + temp1.find(s2[i]) + 1, temp1.end());
    else
      flag = true;
  }
  if (!flag) {
    cout << "automaton" << endl;
    return 0;
  }
  temp1 = s1;
  if (s1.size() == s2.size()) {
    sort(temp1.begin(), temp1.end());
    sort(temp2.begin(), temp2.end());
    if (temp1 == temp2) {
      cout << "array" << endl;
      return 0;
    }
  }
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  temp1 = s1;
  flag = false;
  for (int i = 0; i < s2.size(); i++) {
    if (temp1.find(s2[i]) != string::npos)
      temp1 = string(temp1.begin() + temp1.find(s2[i]) + 1, temp1.end());
    else
      flag = true;
  }
  if (!flag) {
    cout << "both" << endl;
    return 0;
  }
  cout << "need tree" << endl;
  return 0;
}
