#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powm(long long base, long long exp, long long mod = 998244353) {
  base %= mod;
  long long ans = 1;
  while (exp) {
    if (exp & 1LL) ans = (ans * base) % mod;
    exp >>= 1LL, base = (base * base) % mod;
  }
  return ans;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long a;
    cin >> a;
    a *= 2;
    long long n = gcd(360, a);
    n = 360 / n;
    long long k = (n * a) / 360;
    if (k + 1 >= n) n *= 2;
    cout << n << '\n';
  }
}
