#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  int i, j;
  cin >> a >> b;
  int ar[30] = {0};
  int br[30] = {0};
  for (i = 0; i < a.size(); i++) ar[a[i] - 'a']++;
  for (i = 0; i < b.size(); i++) br[b[i] - 'a']++;
  int flag = 0, f = 0;
  for (i = 0; i < 26; i++) {
    if (br[i] > ar[i]) flag = 1;
    if (br[i] != ar[i]) f = 1;
  }
  if (flag == 1) {
    cout << "need tree" << endl;
    return 0;
  }
  if (f == 0) {
    cout << "array" << endl;
    return 0;
  }
  if (a.find(b) != string::npos) {
    cout << "automaton" << endl;
    return 0;
  }
  int tt = 0, kk = 0;
  j = 0;
  for (i = 0; i < a.size() && kk == 0; i++) {
    if (a[i] == b[j]) j++;
    if (j == b.size()) kk = 1;
  }
  if (kk == 1) {
    cout << "automaton" << endl;
    return 0;
  }
  cout << "both" << endl;
  return 0;
}
