#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  int a1[27] = {0}, a2[27] = {0};
  cin >> s >> t;
  int aflag = 0, arrflag = 1, tflag = 0;
  int len1 = s.length();
  int len2 = t.length();
  if (len2 > len1) {
    cout << "need tree\n";
    return 0;
  }
  for (int i = 0; i < len1; i++) a1[s[i] - 'a']++;
  for (int i = 0; i < len2; i++) {
    a2[t[i] - 'a']++;
    if (a2[t[i] - 'a'] > a1[t[i] - 'a']) {
      cout << "need tree\n";
      return 0;
    }
  }
  int k = 0;
  if (len1 > len2) aflag = 1;
  char c = t[k];
  int count = 0;
  for (int i = 0; i < len1; i++) {
    c = t[k];
    if (s[i] == c) {
      count++;
      if (k + 1 < len2) k++;
    }
    if (count >= len2) {
      arrflag = 0;
      break;
    }
  }
  if (aflag == 1 && arrflag == 1) {
    cout << "both\n";
    return 0;
  } else if (aflag == 0 && arrflag == 1) {
    cout << "array\n";
    return 0;
  } else if (aflag == 1 && arrflag == 0) {
    cout << "automaton\n";
    return 0;
  }
  return 0;
}
