#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int ans;       long long int f = 0;       for (long long int i = 3; i <= 360; i++) {         if ((n * i) % 180 == 0 && (n * i) / 180 <= i - 2) {           f = 1;           ans = i;           break;         }       }       if (f == 1)         cout << ans << endl;       else         cout << -1 << endl;     }   }   