#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int x;
    cin >> x;
    for (int n = 3; n <= 360; n++) {
      if ((x * n) % 180 == 0 && (x * n) / 180 + 1 <= n - 1) {
        cout << n << " ";
        break;
      }
    }
  }
  return 0;
}
