#include using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--) #define ll long long template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } void solve() { ll n, k; cin >> n >> k; vector dp(n + 1, 0); ll tot = 0; { for (int i = 1; i <= n; i++) dp[i] = (n / i) * (n / i); for (ll i = n; i >= 1; i--) for (ll j = i * 2; j <= n; j += i) dp[i] -= dp[j]; if (dp[1] < k) { cout << -1; return; } tot = dp[1]; } bool inv = false; if (k * 2 > tot) { k = tot - k + 1; inv = true; } { ll l = 0, r = n * n + 10; while (r - l > 1) { ll x = (l + r) / 2; for (ll i = n; i >= 1; i--) { dp[i] = 0; ll m = n / i; for (int a = 1; a <= m; a++) dp[i] += min(m, a * x / (n * n)); for (ll j = i * 2; j <= n; j += i) dp[i] -= dp[j]; } if (dp[1] < k) { l = x; } else { r = x; } } for (ll a = 1; a <= n; a++) { ll x = a * l / n / n + 1; ll y = a * r / n / n; if (x == y) { if (!inv) { cout << y << "/" << a; } else { cout << a << "/" << y; } return; } } } } int main() { int t; cin >> t; while (t--) { solve(); if (t) { cout << "\n"; } else { cout << endl; } } }