#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const long long mod = 998244353;
const double PI = acos(-1.0);
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  while (cin >> T) {
    while (T--) {
      int n;
      cin >> n;
      n = n * 2;
      int ans = INF;
      for (int i = 1; i <= 360; ++i) {
        if (n % i == 0) {
          if (360 % (n / i) == 0) {
            if (360 / (n / i) - i > 1) ans = min(ans, 360 / (n / i));
          }
        }
      }
      cout << ans << endl;
    }
  }
}
