#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  vector<long long> v(30, 0);
  long long la = a.length();
  long long lower_bound = b.length();
  bool ato = false;
  for (long long i = 0, j = 0; i < la; i++) {
    if (j < lower_bound && a[i] == b[j]) j++;
    if (j == lower_bound) ato = true;
  }
  for (long long i = 0; i < la; i++) {
    v[a[i] - 'a']++;
  }
  for (long long i = 0; i < lower_bound; i++) {
    v[b[i] - 'a']--;
  }
  bool arr = true;
  bool bo = true;
  for (long long i = 0; i < 26; i++) {
    arr &= v[i] == 0;
    bo &= v[i] >= 0;
  }
  if (ato)
    cout << "automaton" << endl;
  else if (arr)
    cout << "array" << endl;
  else if (bo)
    cout << "both" << endl;
  else {
    cout << "need tree" << endl;
  }
  return 0;
}
