#include <bits/stdc++.h>
using namespace std;
bool isSubSequence(string str1, string str2, int m, int n) {
  int j = 0;
  for (int i = 0; i < n && j < m; i++)
    if (str1[j] == str2[i]) j++;
  return (j == m);
}
int main() {
  string s, d;
  int i, j, k;
  cin >> s >> d;
  int n = s.length();
  int n1 = d.length();
  int a[26] = {0};
  int b[26] = {0};
  for (int i = 0; i < n; i++) a[s[i] - 97]++;
  for (int i = 0; i < n1; i++) b[d[i] - 97]++;
  if (n == n1) {
    int flag = 0;
    for (int i = 0; i < 26; i++) {
      if (a[i] != b[i]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0)
      return cout << "array", 0;
    else
      return cout << "need tree", 0;
  } else if (n1 < n) {
    int flag = 0;
    for (int i = 0; i < 26; i++) {
      if ((a[i] == 0 && b[i] != 0) || (a[i] > 0 && b[i] > 0 && a[i] < b[i])) {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      return cout << "need tree", 0;
    else {
      if (isSubSequence(d, s, d.length(), s.length()))
        return cout << "automaton", 0;
      else
        return cout << "both", 0;
    }
  } else
    cout << "need tree";
}
