#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int n1 = s.length(), n2 = t.length();
  vector<int> a1(26), a2(26);
  for (int i = 0; i < 26; i++) {
    a1[i] = a2[i] = 0;
  }
  for (int i = 0; i < n1; i++) {
    a1[s[i] - 'a']++;
  }
  for (int i = 0; i < n2; i++) {
    a2[t[i] - 'a']++;
  }
  bool same_alpha = true;
  for (int i = 0; i < 26; i++) {
    if (a1[i] < a2[i]) {
      cout << "need tree";
      return 0;
    } else if (a1[i] > a2[i]) {
      same_alpha = false;
    }
  }
  if (same_alpha) {
    cout << "array";
    return 0;
  }
  for (int i = 0, j = 0; i < n1; i++) {
    if (s[i] == t[j]) {
      j++;
      if (j == n2) {
        cout << "automaton";
        return 0;
      }
    }
  }
  cout << "both";
  return 0;
}
