#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  bool sub = false;
  int j = 0;
  if (t.size() < s.size()) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == t[j]) {
        j++;
      }
      if (j == t.size()) {
        sub = true;
        break;
      }
    }
  }
  if (sub) {
    cout << "automaton";
  } else {
    vector<int> a(26, 0);
    vector<int> b(26, 0);
    for (int i = 0; i < t.size(); i++) {
      b[t[i] - 'a']++;
    }
    for (int i = 0; i < s.size(); i++) {
      a[s[i] - 'a']++;
    }
    bool array = true;
    bool both = true;
    for (int i = 0; i < 26; i++) {
      if (a[i] != b[i]) {
        array = false;
      }
      if (a[i] < b[i]) {
        both = false;
      }
    }
    if (array) {
      cout << "array";
    } else if (both) {
      cout << "both";
    } else {
      cout << "need tree";
    }
  }
}
