#include <bits/stdc++.h>
using namespace std;
int t, a, b;
double prob(int a, int b) {
  if (a == 0 && b == 0) return 1.0;
  if (a == 0) return 0.5;
  if (b == 0) return 1.0;
  if (a == 4 * b) return 0.75;
  double aa = a, bb = b;
  double s1 = aa * bb, s2 = (a > 4 * b) ? s1 - ((double)(bb * bb * 2))
                                        : ((double)(aa * aa)) / 8.0;
  return 0.5 * (1.0 + s2 / s1);
}
int main() {
  cin >> t;
  for (int test = 0; test < t; test++) {
    cin >> a >> b;
    printf("%.9lf\n", prob(a, b));
  }
  return 0;
}
