#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int a[26], b[26];
  for (int i = 0; i < 26; i++) {
    a[i] = 0;
    b[i] = 0;
  }
  cin >> s >> t;
  for (int i = 0; i < int(s.size()); i++) {
    a[int(s[i] - 'a')]++;
  }
  for (int i = 0; i < int(t.size()); i++) {
    b[int(t[i] - 'a')]++;
  }
  if (s.size() >= t.size()) {
    int fl = 0;
    for (int i = 0; i < 26; i++) {
      if (b[i] > a[i]) {
        fl = 1;
        break;
      }
    }
    int ff = 0;
    int p = 0;
    for (int i = 0; i < int(s.size()); i++) {
      if (t[p] == s[i]) {
        p++;
      }
      if (p == int(t.size() - 1)) {
        break;
      }
    }
    if (p < int(t.size() - 1)) {
      ff = 1;
    }
    if (fl == 0) {
      if (ff == 0) {
        cout << "automaton";
      } else {
        if (s.size() == t.size()) {
          cout << "array";
        } else {
          cout << "both";
        }
      }
    } else {
      cout << "need tree";
    }
  } else {
    cout << "need tree";
  }
  return 0;
}
