#include <bits/stdc++.h>
using namespace std;
int cnt[1234567];
string s, t;
int main() {
  cin >> s >> t;
  int n = (int)s.size(), m = (int)t.size();
  memset(cnt, 0, sizeof cnt);
  bool sau = false;
  for (int i = 0, j = 0; i < n; ++i) {
    if (j < m && s[i] == t[j]) ++j;
    if (j == m) sau = true;
  }
  for (int i = 0; i < n; ++i) cnt[s[i] - 'a']++;
  for (int i = 0; i < m; ++i) cnt[t[i] - 'a']--;
  bool sar = true;
  bool all = true;
  for (int i = 0; i < 26; ++i) {
    sar &= cnt[i] == 0;
    all &= cnt[i] >= 0;
  }
  if (sau)
    cout << "automaton" << endl;
  else if (sar)
    cout << "array" << endl;
  else if (all)
    cout << "both" << endl;
  else
    cout << "need tree" << endl;
  return 0;
}
