#include <bits/stdc++.h>
const int d[8][2] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1},
                     {0, 1},   {1, -1}, {1, 0},  {1, 1}};
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
using namespace std;
string S, T;
int ind = 0;
int cnt[500];
bool aray = true;
int main() {
  cin >> S >> T;
  int s = S.size();
  int t = T.size();
  for (int i = 0; i < s; i++) {
    if (ind < t && S[i] == T[ind]) ind++;
    cnt[S[i] + 0]++;
  }
  if (ind == t) {
    cout << "automaton";
    return 0;
  }
  for (int i = 0; i < t; i++) {
    if (cnt[T[i] + 0] > 0)
      cnt[T[i] + 0]--;
    else
      aray = false;
  }
  if (aray && s == t) {
    cout << "array";
    return 0;
  }
  if (aray) {
    cout << "both";
    return 0;
  }
  cout << "need tree";
}
