#include <bits/stdc++.h>
using namespace std;
string a, b;
int cnta[30], cntb[30];
bool arr() {
  for (int i = 0; i < 26; i++) {
    if (cnta[i] != cntb[i]) return false;
  }
  return true;
}
bool mation() {
  if (a.size() < b.size()) return false;
  int ptb = 0, pta = 0;
  int cnt = 0;
  for (; ptb < b.size(); ptb++) {
    for (; pta < a.size(); pta++) {
      if (a[pta] == b[ptb]) {
        pta++;
        cnt++;
        break;
      }
    }
  }
  if (cnt == b.size()) return true;
  return false;
}
bool both() {
  for (int i = 0; i < 26; i++) {
    if (cnta[i] < cntb[i]) return false;
  }
  return true;
}
int main() {
  while (cin >> a >> b) {
    memset(cnta, 0, sizeof(cnta));
    memset(cntb, 0, sizeof(cntb));
    for (int i = 0; i < a.size(); i++) {
      cnta[a[i] - 'a']++;
    }
    for (int i = 0; i < b.size(); i++) {
      cntb[b[i] - 'a']++;
    }
    if (arr())
      puts("array");
    else if (mation())
      puts("automaton");
    else if (both())
      puts("both");
    else
      puts("need tree");
  }
}
