#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  while (cin >> s >> t) {
    map<char, int> mps;
    bool ok = 0;
    for (int i(0); i < s.size(); ++i) mps[s[i]]++;
    for (int i(0); i < t.size(); ++i) {
      --mps[t[i]];
      if (mps[t[i]] < 0) {
        ok = 1;
        puts("need tree");
        break;
      }
    }
    if (ok) continue;
    if (s.size() == t.size())
      puts("array");
    else {
      int s1 = 0, t1 = 0;
      while (t1 < t.size()) {
        while (s1 < s.size() && s[s1] != t[t1]) ++s1;
        if (s1 == s.size()) break;
        ++t1;
        ++s1;
      }
      if (t1 == t.size()) {
        puts("automaton");
      } else
        puts("both");
    }
  }
  return 0;
}
