#include <bits/stdc++.h>
using namespace std;
long long int scan() {
  long long int t = 0;
  char c, ch;
  ch = getchar();
  if (ch == '-') {
    c = getchar();
  } else {
    c = ch;
  }
  while (c < '0' || c > '9') {
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    t = (t << 3) + (t << 1) + c - '0';
    c = getchar();
  }
  if (ch == '-') {
    return -t;
  } else {
    return t;
  }
}
long long int a[26] = {0}, b[26] = {0};
int main() {
  ios::sync_with_stdio(false);
  long long int i, j, k, t, n, m, x, y, cnt = 0, minx = 1e18, maxy = -1e18;
  string str1, str2;
  cin >> str1 >> str2;
  for (i = 0; i < (int)str1.size(); i++) a[str1[i] - 'a']++;
  for (i = 0; i < (int)str2.size(); i++) b[str2[i] - 'a']++;
  for (i = 0, j = 0; i < (int)str1.size() and j < (int)str2.size(); i++) {
    if (str1[i] == str2[j]) j++;
  }
  if (j == (int)str2.size()) {
    cout << "automaton\n";
    return 0;
  }
  for (i = 0; i < 26; i++) {
    if ((a[i] - b[i]) < 0) {
      cout << "need tree\n";
      return 0;
    }
  }
  if ((int)str1.size() != (int)str2.size())
    cout << "both\n";
  else
    cout << "array\n";
  return 0;
}
