#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    double a, b;
    cin >> a >> b;
    if (!b)
      cout << 1 << endl;
    else if (!a)
      cout << 0.5 << endl;
    else
      cout << fixed << setprecision(7)
           << ((min(a, 4 * b) * min(a, 4 * b) / (16.0 * b)) +
               0.5 * min(a, 4 * b) + max(double(0), a - 4 * b)) /
                  a
           << endl;
  }
}
