#include <bits/stdc++.h>
using namespace std;
string s, t;
int vis[101];
vector<int> ord;
bool arr, autom;
queue<int> q;
bool croissant() {
  for (int i = 0; i < (int)ord.size() - 1; i++) {
    if (ord[i] > ord[i + 1]) return false;
  }
  return true;
}
void supp() {
  while (!q.empty()) q.pop();
}
int main() {
  cin >> s >> t;
  if (s.length() < t.length()) {
    cout << "need tree";
    return 0;
  }
  int lt = t.length();
  int ls = s.length();
  for (int j = 0; j < ls; j++) {
    if (t[0] == s[j] && !vis[j]) {
      vis[j] = 1;
      ord.push_back(j);
      break;
    }
  }
  if (ord.size())
    for (int i = 1; i < lt; i++) {
      for (int j = 0; j < ls; j++) {
        if (t[i] == s[j] && !vis[j]) {
          q.push(j);
          if (j > ord[ord.size() - 1]) {
            vis[j] = 1;
            ord.push_back(j);
            supp();
            break;
          }
        }
      }
      if (!q.empty()) {
        ord.push_back(q.front());
        vis[q.front()] = 1;
        supp();
      }
    }
  if ((int)ord.size() == lt) {
    if (!croissant()) arr = true;
    if (ls > lt) autom = true;
    if (arr && autom)
      cout << "both";
    else if (arr)
      cout << "array";
    else
      cout << "automaton";
  } else
    cout << "need tree";
  return 0;
}
