#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  bool tree = 0, ary = 1, atmtn = 0;
  for (char c = 'a'; !tree && c <= 'z'; c++) {
    int ct, cs;
    if ((ct = count(t.begin(), t.end(), c)) <=
        (cs = count(s.begin(), s.end(), c))) {
      if (ct < cs) {
        atmtn = 1;
        ary = 0;
      }
    } else {
      tree = 1;
      break;
    }
  }
  if (!tree && atmtn) {
    for (int i = 0; i < s.length() && i < t.length(); i++) {
      if (s[i] != t[i])
        for (int j = i; j < s.length() && s[j] != t[i]; j++)
          s.erase(s.begin() + (j--));
    }
    if (t.length() > s.length()) ary = 1;
  }
  if (tree)
    cout << "need tree" << endl;
  else if (ary && atmtn)
    cout << "both" << endl;
  else if (ary)
    cout << "array" << endl;
  else if (atmtn)
    cout << "automaton" << endl;
  return 0;
}
