#include <bits/stdc++.h>
const long long M = 1e9 + 7;
const long long N = 2e5 + 5;
using namespace std;
int main() {
  string str1, str2;
  cin >> str1 >> str2;
  int A[26] = {0};
  int B[26] = {0};
  for (int i = 0; str1[i] != '\0'; i++) {
    A[str1[i] - 97]++;
  }
  for (int i = 0; str2[i] != '\0'; i++) {
    B[str2[i] - 97]++;
  }
  int flag = 0;
  for (int i = 0; i < 26; i++) {
    if (B[i] > A[i]) {
      flag = 1;
      break;
    }
  }
  if (flag)
    cout << "need tree" << endl;
  else if (str1.size() == str2.size())
    cout << "array" << endl;
  else if (str1.find(str2) != -1)
    cout << "automaton" << endl;
  else {
    long long size = str2.size();
    int arr[size];
    for (int i = 0; i < size; i++) arr[i] = -1;
    int i = 0;
    int l = 0;
    while (l < str1.size()) {
      if (str2[i] == str1[l]) {
        arr[i++] = 1;
      }
      l++;
    }
    int flag2 = 0;
    for (int j = 0; j < size; j++) {
      if (arr[j] == -1) {
        flag2 = 1;
        break;
      }
    }
    if (flag2)
      cout << "both" << endl;
    else
      cout << "automaton" << endl;
  }
}
