#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);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t;
  cin >> t;
  for (long long i = 0; i < t; ++i) {
    long long a;
    cin >> a;
    long long d = gcd(a, 180);
    a /= d;
    long long x = 180 / d;
    if (a + 1 == x) {
      cout << 2 * x << "\n";
    } else {
      cout << x << "\n";
    }
  }
  return 0;
}
