#include <bits/stdc++.h>
using namespace std;
int main() {
  int i = 0, j = 0;
  char ch1[101], ch2[101];
  int b1[30] = {0}, b2[30] = {0};
  cin >> ch1 >> ch2;
  bool isthere = false;
  bool aut = false;
  bool arrat = false;
  for (int i = 0; i < strlen(ch1); i++) {
    b1[(int)ch1[i] - 97]++;
  }
  for (int i = 0; i < strlen(ch2); i++) {
    b2[(int)ch2[i] - 97]++;
  }
  for (int i = 0; i < 26; i++) {
    if (b2[i] > b1[i]) {
      cout << "need tree";
      return 0;
    }
    if (b2[i] == 0 && b1[i] != 0) {
      aut = true;
    }
  }
  for (int i = 0; i < strlen(ch1); i++) {
    if (ch1[i] == ch2[j]) {
      j++;
    }
  }
  if (j == strlen(ch2)) {
    cout << "automaton";
    return 0;
  } else {
    if (strlen(ch1) != strlen(ch2)) {
      cout << "both";
      return 0;
    } else {
      cout << "array";
      return 0;
    }
  }
  return 0;
}
