#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
using namespace std;
char s[1110], t[1110];
int num1[110], num2[110];
bool judgeSA() {
  int lens, lent, i;
  lens = strlen(s);
  lent = strlen(t);
  if (lens == lent) {
    memset(num1, 0, sizeof(num1));
    memset(num2, 0, sizeof(num2));
    for (i = 0; i < lens; i++) {
      num1[s[i] - 'a']++;
      num2[t[i] - 'a']++;
    }
    for (i = 0; i < 26; i++)
      if (num1[i] != num2[i]) break;
    if (i == 26)
      return true;
    else
      return false;
  } else
    return false;
}
bool judgeSAM() {
  int i, j, lens, lent;
  lens = strlen(s);
  lent = strlen(t);
  for (i = 0, j = 0; i < lens && j < lent; i++) {
    if (s[i] == t[j]) j++;
  }
  if (j == lent)
    return true;
  else
    return false;
}
bool judgeBoth() {
  int i, lens, lent;
  lens = strlen(s);
  lent = strlen(t);
  memset(num1, 0, sizeof(num1));
  memset(num2, 0, sizeof(num2));
  for (i = 0; i < lens; i++) num1[s[i] - 'a']++;
  for (i = 0; i < lent; i++) num2[t[i] - 'a']++;
  for (i = 0; i < 26; i++)
    if (num1[i] < num2[i]) return false;
  return true;
}
int main() {
  int f1, f2;
  while (scanf("%s%s", s, t) != EOF) {
    f1 = judgeSAM();
    f2 = judgeSA();
    if (f1 || f2) {
      if (f1)
        printf("automaton\n");
      else
        printf("array\n");
    } else {
      f1 = judgeBoth();
      if (f1)
        printf("both\n");
      else
        printf("need tree\n");
    }
  }
  return 0;
}
