#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int main() {
  int k;
  long double a, b;
  cout.precision(20);
  cin >> k;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    if (b == 0)
      cout << 1 << endl;
    else if (a >= 4 * b)
      cout << (3 * b) / a + 1 - 4 * b / a << endl;
    else
      cout << a / (16 * b) + 0.5 << endl;
  }
}
