#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int a[30] = {0};
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) a[s[i] - 97]++;
  for (int i = 0; i < t.size(); i++) a[t[i] - 97]--;
  if (s.size() == t.size()) {
    for (int i = 0; i < 26; i++) {
      if (a[i] != 0) {
        cout << "need tree" << endl;
        return 0;
      }
    }
    cout << "array" << endl;
  } else {
    for (int i = 0; i < 26; i++) {
      if (a[i] < 0) {
        cout << "need tree" << endl;
        return 0;
      }
    }
    int j = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == t[j]) {
        j++;
      }
      if (j == t.size()) {
        cout << "automaton" << endl;
        return 0;
      }
    }
    cout << "both" << endl;
  }
  return 0;
}
