#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int T;
double a, b;
double solve() {
  if (b < 1e-8) {
    return 1.0;
  }
  if (a < 1e-8) {
    return 0.5;
  }
  double p, q;
  q = a * b * 2.0;
  p = a * b;
  double c = min(a, 4.0 * b);
  p += c * c / 8.0;
  p += b * (a - c);
  return p / q;
}
int main() {
  while (cin >> T) {
    while (T--) {
      cin >> a >> b;
      cout << solve() << endl;
    }
  }
}
