#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int ix = 0;
  for (int p = 0; p < s1.size(); p++)
    if (s1[p] == s2[ix]) ++ix;
  if (ix >= s2.size()) {
    cout << "automaton" << endl;
    return 0;
  }
  const int N = 26;
  vector<int> v(N, 0);
  for (int p = 0; p < s1.size(); p++) v[s1[p] - 'a']++;
  for (int p = 0; p < s2.size(); p++) v[s2[p] - 'a']--;
  bool arr(1), tree(0);
  for (int p = 0; p < N; p++) {
    if (v[p] != 0) arr = 0;
    if (v[p] < 0) {
      tree = 1;
      break;
    }
  }
  if (arr)
    puts("array");
  else if (!tree)
    puts("both");
  else
    puts("need tree");
  cout << endl;
  return 0;
}
