#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, t, s, sa, t1, t2, h1[300], h2[300];
int n, m;
string str1, str2;
int main() {
  cin >> str1 >> str2;
  for (i = 0; i < str1.size(); i++) h1[str1[i]]++;
  for (i = 0; i < str2.size(); i++) h2[str2[i]]++;
  for (i = 0; i < 255; i++) {
    if (h1[i] && h1[i] >= h2[i]) s += h2[i];
    if (h1[i] > h2[i]) t1 += h1[i] - h2[i];
    if (h1[i] < h2[i]) t2++;
  }
  int t = 0, aa = 0, tt;
  m = 9999999;
  for (i = 0; i < str1.size(); i++) {
    aa = 0;
    tt = 1;
    if (str1[i] == str2[0]) {
      for (j = i + 1; j < str1.size() && tt < str2.size(); j++)
        if (str1[j] != str2[tt]) {
          aa++;
        } else
          tt++;
      if (tt == str2.size()) m = min(aa, m);
    }
  }
  if (t2)
    printf("need tree");
  else if (s == str2.size() && str1.size() == str2.size())
    printf("array");
  else if (m <= t1 && str1.size() != str2.size())
    printf("automaton");
  else
    printf("both");
}
