#include <bits/stdc++.h>
using namespace std;
bool f;
long long maxx = -999999999999, minn = 999999999999;
char ss[109];
int t[109];
int main() {
  string s, d;
  cin >> s >> d;
  int sl = s.length(), dl = d.length(), i, j;
  for (i = 0; i < dl; i++) ss[i] = d[i];
  if (sl == dl) {
    for (i = 0; i < sl; i++) {
      f = 0;
      for (j = 0; j < dl; j++) {
        if (s[i] != '0' && d[j] != '0' && s[i] == d[j]) {
          f = 1;
          s[i] = '0';
          d[j] = '0';
        }
      }
      if (!f) {
        cout << "need tree";
        return 0;
      }
    }
    cout << "array";
    return 0;
  }
  int h = 0;
  j = 0, i = 0;
  while (1) {
    if (s[j] == ss[i])
      h++, i++, j++;
    else {
      if (j == sl) break;
      j++;
      continue;
    }
    if (h == dl) {
      cout << "automaton";
      return 0;
    }
  }
  for (i = 0; i < dl; i++) {
    f = 0;
    for (j = 0; j < sl; j++) {
      if (s[j] != '0' && s[j] == ss[i]) {
        f = 1, s[j] = '0';
        break;
      }
    }
    if (!f) {
      cout << "need tree";
      return 0;
    }
  }
  cout << "both";
  return 0;
}
