#include <bits/stdc++.h>
int main() {
  long long int a, b, c, d, t, e;
  double min, max, aang;
  scanf("%I64d", &c);
  while (c--) {
    scanf("%I64d", &a);
    for (b = 3; b <= 998244353; b++) {
      aang = 0;
      e = 1;
      int flag = 0;
      max = (double)(b - 2) * 180 / b;
      min = (double)(180 - max) / 2;
      for (e = 1; aang < max; e++) {
        aang = min * (double)e;
        if (aang == (double)a) {
          t = b;
          flag = 1;
        }
      }
      if (flag) break;
    }
    printf("%I64d\n", t);
  }
}
