#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const long long INF = 1LL << 50;
using namespace std;
template <typename X>
inline bool minimize(X& p, X q) {
  if (p <= q) return 0;
  p = q;
  return 1;
}
template <typename X>
inline bool maximize(X& p, X q) {
  if (p >= q) return 0;
  p = q;
  return 1;
}
int a1[105], a2[105];
char s1[105], s2[105];
void doit() {
  int len1 = strlen(s1), len2 = strlen(s2);
  if (len1 < len2) {
    printf("need tree\n");
    return;
  }
  int j = 0, i = 0;
  while (j < len2 && i < len1) {
    while (s1[i] != s2[j] && i < len1) i++;
    if (i == len1) break;
    j++;
    i++;
  }
  if (j == len2 && len1 != len2) {
    printf("automaton\n");
    return;
  }
  memset(a1, 0, sizeof(a1));
  memset(a2, 0, sizeof(a2));
  for (int i = 0; i < len1; i++) a1[s1[i] - 'a']++;
  for (int i = 0; i < len2; i++) a2[s2[i] - 'a']++;
  int first = 1, second = 1;
  for (int i = 0; i < 26; i++) {
    if (a1[i] != a2[i]) first = 0;
    if (a1[i] < a2[i]) second = 0;
  }
  if (first) {
    printf("array\n");
    return;
  }
  if (second) {
    printf("both\n");
    return;
  }
  printf("need tree\n");
}
int main() {
  while (scanf("%s%s", s1, s2) != EOF) doit();
}
