#include <bits/stdc++.h>
bool is_array(std::string s, std::string t) {
  std::sort(std::begin(s), std::end(s));
  std::sort(std::begin(t), std::end(t));
  return s == t;
}
bool is_automaton(const std::string& s, const std::string& t) {
  int size = s.size(), x = 0;
  for (const auto& c : t) {
    int i = std::find(std::begin(s) + x, std::end(s), c) - std::begin(s);
    if (i == size) return false;
    x = i + 1;
  }
  return true;
}
bool is_both(const std::string& s, const std::string& t) {
  std::vector<int> da(26, 0), db(26, 0);
  for (const auto& c : s) da[c - 'a']++;
  for (const auto& c : t) db[c - 'a']++;
  for (int i = 0; i < 26; i++)
    if (da[i] < db[i]) return false;
  return true;
}
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  std::string s, t;
  std::cin >> s >> t;
  if (is_array(s, t)) {
    std::cout << "array" << std::endl;
  } else if (is_automaton(s, t)) {
    std::cout << "automaton" << std::endl;
  } else if (is_both(s, t)) {
    std::cout << "both" << std::endl;
  } else {
    std::cout << "need tree" << std::endl;
  }
  return 0;
}
