#include <bits/stdc++.h>
using namespace std;
bool isSubSequence(string str1, string str2, int m, int n) {
  if (m == 0) return true;
  if (n == 0) return false;
  if (str1[m - 1] == str2[n - 1])
    return isSubSequence(str1, str2, m - 1, n - 1);
  return isSubSequence(str1, str2, m, n - 1);
}
int main() {
  string s, t;
  cin >> s >> t;
  int i, j;
  int arr1[26] = {0}, arr2[26] = {};
  int m = s.length();
  int n = t.length();
  if (isSubSequence(t, s, n, m) == true) {
    cout << "automaton" << endl;
    return 0;
  }
  for (i = 0; i < s.length(); i++) {
    arr1[int(s[i]) - 97]++;
  }
  for (i = 0; i < t.length(); i++) {
    arr2[int(t[i]) - 97]++;
  }
  int flag = 0;
  if (s.length() == t.length()) {
    for (i = 0; i < 26; i++) {
      if (arr1[i] != arr2[i]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "array" << endl;
      return 0;
    } else {
      cout << "need tree" << endl;
      return 0;
    }
  }
  for (i = 0; i < 26; i++) {
    if (arr1[i] < arr2[i]) {
      cout << "need tree" << endl;
      return 0;
    }
  }
  cout << "both" << endl;
  return 0;
}
