#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;
int T;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) {
    int ang;
    cin >> ang;
    long long ans = (360 + 180 - ang - 1) / (180 - ang);
    while (ans * ang % 180 != 0) ++ans;
    cout << ans << "\n";
  }
}
