#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long n, i, j, k, t, ang, g;
  cin >> t;
  while (t-- > 0) {
    cin >> ang;
    g = gcd(180, ang);
    n = 180 / g;
    k = ang / g;
    if (k + 1 == n) n *= 2;
    cout << n << endl;
  }
}
