#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll mod = 1e9 + 7;
bool chk[26];
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int ang;
    cin >> ang;
    int g = gcd(180, ang);
    int k = ang / g, n = 180 / g;
    if (n == k + 1) {
      k *= 2;
      n *= 2;
    }
    cout << n << endl;
  }
  return 0;
}
