#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, ans, s, f;
string x, y;
bool tell(string txt, string s) {
  int pos = -1;
  bool ok = true;
  for (int i = 0; ok && i != s.size(); i++) {
    ok = (pos = txt.find(s[i], pos + 1)) != string::npos;
  }
  if (ok)
    return true;
  else
    return false;
}
int main() {
  cin >> x >> y;
  int a[26] = {0}, b[26] = {0};
  for (i = 0; i < x.length(); i++) a[x[i] - 97]++;
  for (i = 0; i < y.length(); i++) b[y[i] - 97]++;
  for (i = 0; i < 26; i++)
    if (a[i] < b[i]) f = 1;
  if (f) {
    cout << "need tree\n";
    return 0;
  }
  for (i = 0; i < 26; i++) {
    if (a[i] > b[i]) f = 1;
    ans += a[i] - b[i];
  }
  if (ans == 0 && f == 0) {
    cout << "array\n";
    return 0;
  }
  if (f) {
    if (tell(x, y))
      cout << "automaton\n";
    else
      cout << "both\n";
    return 0;
  }
}
