#include <bits/stdc++.h>
using namespace std;
int main() {
  int f = 0;
  string s1, s2;
  cin >> s1 >> s2;
  int n, m, a[26] = {0};
  n = s1.length();
  m = s2.length();
  for (int i = 0; i < n; i++) a[s1[i] - 'a']++;
  for (int i = 0; i < m; i++) {
    if (a[s2[i] - 'a'] == 0) {
      f = 1;
      break;
    } else
      a[s2[i] - 'a']--;
  }
  if (f == 1)
    cout << "need tree\n";
  else {
    int j = 0, i, k = 0;
    for (i = 0; i < m; i++) {
      while (s2[i] != s1[j] && j < n) {
        j++;
      }
      if (s2[i] == s1[j]) {
        k++;
      }
      if (j == n) break;
      j++;
    }
    if (k == m)
      cout << "automaton\n";
    else if (n == m)
      cout << "array\n";
    else if (n != m)
      cout << "both\n";
  }
  return 0;
}
