#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
const int MAX = 10000001;
bool isAutomaton(string s_min, string s_max) {
  int count = 0, found = 0;
  for (int x = 0; x < s_min.length(); x++) {
    for (int y = found; y < s_max.length(); y++) {
      if (s_min[x] == s_max[y]) {
        count++, found = y + 1;
        break;
      }
    }
  }
  if (count == s_min.size())
    return true;
  else
    return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s, t, s_max, s_min;
  size_t found;
  int count = 0, s_min_size = 0, s_max_size = 0;
  cin >> s >> t;
  if (s.length() >= t.length())
    s_max = s, s_min = t;
  else
    s_min = t, s_max = s;
  s_min_size = s_min.length();
  s_max_size = s_max.length();
  if (isAutomaton(s_min, s_max))
    cout << "automaton";
  else {
    for (int x = 0; x < s_min.length(); x++) {
      for (int y = 0; y < s_max.length(); y++) {
        if (s_min[x] == s_max[y]) {
          s_min[x] = ' ', s_min_size--;
          s_max[y] = ' ', s_max_size--;
          break;
        }
      }
    }
    if (s_min_size == 0 && s_max_size == 0)
      cout << "array";
    else if (s_min_size == 0 && s_max_size != 0)
      cout << "both";
    else
      cout << "need tree";
  }
}
