#include <bits/stdc++.h>
using namespace std;
int arrs[26] = {0}, arrt[26] = {0}, arr[101];
int main() {
  string s, t;
  int i, ls, lt, flag = 0, f2, j, k;
  cin >> s >> t;
  ls = s.length();
  lt = t.length();
  for (i = 0; i < ls; i++) arrs[s.at(i) - 97]++;
  for (i = 0; i < lt; i++) arrt[t.at(i) - 97]++;
  if (ls > lt) flag = 1;
  for (i = 0; i < 26; i++)
    if (arrs[i] < arrt[i]) break;
  if (i != 26) {
    printf("need tree");
    return 0;
  }
  k = 0;
  for (i = 0; i < lt; i++) {
    f2 = 0;
    for (j = k; j < ls; j++)
      if (t.at(i) == s.at(j)) {
        f2 = 1;
        k = j + 1;
        break;
      }
    if (f2 == 0) break;
  }
  f2 = 0;
  if (i != lt) f2 = 1;
  if (flag && f2)
    printf("both");
  else if (f2)
    printf("array");
  else if (flag)
    printf("automaton");
  else
    printf("need tree");
  return 0;
}
