#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, x, flag;
  double sum, a;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> x;
    flag = 0;
    for (int j = 3; j <= 500; j++) {
      sum = 180 * j - 360;
      a = (sum / j) / (j - 2);
      for (int k = 1; k <= j - 2; k++) {
        if (k * a == x) {
          cout << j << endl;
          flag = 1;
          break;
        }
      }
      if (flag) break;
    }
  }
  return 0;
}
