#include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { int t; cin >> t; while (t--) { int n; ll k; cin >> n >> k; const auto f = [&](const ll k) -> ll { // ll res = 0; // for (int num = 1; num <= n; ++num) { // for (int den = 1; den <= n; ++den) { // if (gcd(num, den) == 1 && num * n * n <= k * den) ++res; // } // } // return res; vector g(n + 1, 0); for (int den = 1; den <= n; ++den) { g[den] += k * den / n / n; for (int i = den * 2; i <= n; i += den) { g[i] -= g[den]; } } // cout << k << ": "; // REP(i, n + 1) cout << g[i] << " \n"[i == n]; return reduce(ALL(g), 0LL); }; const ll nmt1 = f(1LL * n * n); if (nmt1 == k) { cout << "1/1\n"; continue; } if (k >= nmt1 * 2) { cout << "-1\n"; continue; } bool k_is_large = false; if (nmt1 < k) { k = nmt1 * 2 - k; k_is_large = true; } ll lb = 0, ub = 1LL * n * n - 1; while (ub - lb > 1) { const ll mid = midpoint(lb, ub); (f(mid) >= k ? ub : lb) = mid; } for (int den = 1; den <= n; ++den) { const ll num = ub * den / n / n; if ((ub - 1) * den < num * n * n) { if (k_is_large) { cout << den << '/' << num << '\n'; } else { cout << num << '/' << den << '\n'; } break; } } } return 0; }