#include <bits/stdc++.h>
using namespace std;
bool _array(string a, string b) {
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  return a == b;
}
int main() {
  string a, b;
  cin >> a >> b;
  map<char, int> cnt;
  int count = 0;
  int n = a.size();
  for (int i = 0, j = 0; i < n; i++) {
    if (a[i] == b[j]) j++, count++;
  }
  if (count == b.size()) {
    printf("automaton");
    return 0;
  }
  if (_array(a, b)) {
    printf("array");
    return 0;
  }
  int m = b.size();
  for (int i = 0; i < m; i++) {
    cnt[b[i]]++;
  }
  map<char, int> mp;
  for (int i = 0; i < a.size(); i++) {
    mp[a[i]]++;
  }
  for (auto i : cnt) {
    if (i.second > mp[i.first]) {
      printf("need tree");
      return 0;
    }
  }
  printf("both");
}
