#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  map<char, int> mp1, mp2;
  int flag = 0;
  int l1 = s1.size(), l2 = s2.size(), cnt = 0;
  for (int i = 0; i < l1; i++) mp1[s1[i]]++;
  for (int i = 0; i < l2; i++) mp2[s2[i]]++;
  for (int i = 0; i < l2; i++) {
    int cnt1 = mp2[s2[i]];
    if (mp1[s2[i]] < cnt1) {
      flag = 1;
      break;
    }
  }
  if (flag)
    cout << "need tree"
         << "\n",
        exit(0);
  if (l1 == l2)
    cout << "array"
         << "\n",
        exit(0);
  int j = 0;
  for (int i = 0; i < l1 and j < l2; i++) {
    if (s1[i] == s2[j]) j++;
  }
  if (j == l2)
    cout << "automaton"
         << "\n";
  else
    cout << "both"
         << "\n";
  return 0;
}
