#include <bits/stdc++.h>
using namespace std;
int dp[107][107];
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int n = s1.size();
  int m = s2.size();
  for (int i = 0; i < n; i++) dp[i][0] = 0;
  for (int i = 0; i < m; i++) dp[0][i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s1[i] == s2[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
  }
  if (dp[n][m] == m) {
    cout << "automaton" << endl;
    return 0;
  }
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  if (s1 == s2) {
    cout << "array" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s1[i] == s2[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
  }
  if (dp[n][m] == m)
    cout << "both" << endl;
  else
    cout << "need tree" << endl;
  return 0;
}
