#include <bits/stdc++.h>
using namespace std;
int const INF = numeric_limits<int>::max();
long double s(long double a, long double b, long double c) {
  long double p = a + b + c;
  p /= 2;
  return sqrtl(p * (p - a) * (p - b) * (p - c));
}
int main() {
  ios::sync_with_stdio(false);
  int tests;
  cin >> tests;
  while (tests-- > 0) {
    long double a, b;
    cin >> a >> b;
    if (a == b && b == 0) {
      cout << 1 << endl;
    } else if (b == 0) {
      cout << 1 << endl;
    } else if (a == 0) {
      cout << 0.5 << endl;
    } else {
      long double probability = 0;
      long double all = 8 * b * a;
      if (a < 4 * b) {
        probability = ((4 * b * a) + s(a, a, hypotl(a, a))) / all;
      } else {
        probability = (all - s(4 * b, 4 * b, hypotl(4 * b, 4 * b))) / all;
      }
      cout << fixed << setprecision(15) << probability << endl;
    }
  }
  return 0;
}
