#include <bits/stdc++.h>
using namespace std;
int arr1[26];
int arr2[26];
bool fun(string str1, string str2, int m, int n) {
  int j = 0;
  for (int i = 0; i < n && j < m; i++)
    if (str1[j] == str2[i]) j++;
  return (j == m);
}
int main() {
  string s, t;
  cin >> s >> t;
  if (fun(t, s, t.size(), s.size())) {
    cout << "automaton" << endl;
    return 0;
  }
  memset(arr1, 0, sizeof(arr1));
  memset(arr2, 0, sizeof(arr2));
  for (int i = 0; i < s.size(); i++) {
    arr1[s[i] - 'a']++;
  }
  for (int i = 0; i < t.size(); i++) {
    arr2[t[i] - 'a']++;
  }
  for (int i = 0; i < t.size(); i++) {
  }
  int freq = 0;
  bool equal = false;
  for (int i = 0; i < 26; i++) {
    if (arr1[i] < arr2[i]) {
      cout << "need tree" << endl;
      return 0;
    }
    if (arr1[i] > arr2[i]) {
      freq++;
    }
  }
  if (freq > 0) {
    cout << "both" << endl;
    return 0;
  }
  cout << "array" << endl;
  return 0;
}
