#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, i = 1;
    cin >> a;
    while ((i * 180) % a || i * 180 / a < i + 2) {
      i++;
    }
    cout << i * 180 / a << "\n";
  }
  return 0;
}
