#include <bits/stdc++.h>
using namespace std;
int main() {
  bool f1 = true, f2 = false;
  int arrS[26] = {0};
  int arrT[26] = {0};
  string s, t;
  getline(cin, s);
  getline(cin, t);
  for (int i = 0; i < s.size(); i++) arrS[s[i] - 'a']++;
  for (int i = 0; i < t.size(); i++) arrT[t[i] - 'a']++;
  for (int i = 0; i < 26; i++)
    if (arrS[i] < arrT[i]) {
      cout << "need tree" << endl;
      return 0;
    }
  if (s.size() == t.size()) {
    cout << "array" << endl;
    return 0;
  }
  int j = 0;
  for (int i = 0; i < s.size(); i++)
    if (s[i] == t[j]) j++;
  if (j == t.size())
    cout << "automaton" << endl;
  else
    cout << "both" << endl;
  return 0;
}
