#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  map<char, int> m, m1;
  for (int i = 0; i < s.length(); i++) {
    m[s[i]]++;
  }
  for (int i = 0; i < t.length(); i++) {
    m1[t[i]]++;
  }
  bool k = true, k1 = true, k2 = true;
  for (map<char, int>::iterator it = m1.begin(); it != m1.end(); it++) {
    char x = (*it).first;
    int n = (*it).second;
    if (m[x] > n) {
      k = false;
    } else if (m[x] < n) {
      cout << "need tree" << endl;
      return 0;
    }
  }
  if (s.length() == t.length()) {
    cout << "array" << endl;
    return 0;
  }
  int j = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == t[j] && j < t.length()) {
      j++;
    }
  }
  if (j == t.length()) {
    cout << "automaton" << endl;
    return 0;
  }
  cout << "both" << endl;
  return 0;
}
