#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int l = 0, r = 0;
  while (l < (int)s1.size() and r < (int)s2.size()) {
    if (s1[l] == s2[r]) {
      ++l, ++r;
    } else {
      ++l;
    }
    if (r == (int)s2.size()) {
      cout << "automaton\n";
      return 0;
    }
  }
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  if (s1 == s2) {
    cout << "array\n";
    return 0;
  }
  int q[1000000] = {0};
  for (int i = 0; i < (int)s1.size(); ++i) {
    q[s1[i]]++;
  }
  for (int i = 0; i < (int)s2.size(); ++i) {
    q[s2[i]]--;
  }
  for (int i = 0; i < 1000000; ++i) {
    if (q[i] < 0) {
      cout << "need tree\n";
      return 0;
    }
  }
  cout << "both\n";
  return 0;
}
