#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  double a, b;
  scanf("%d", &T);
  while (T--) {
    scanf("%lf%lf", &a, &b);
    double x = a / 4;
    double y = 4 * b;
    double sum = a * b * 2;
    double ans = a * b;
    if (x <= b) {
      ans += x * a / 2;
    } else {
      ans = ans * 2 - y * b / 2;
    }
    if (sum == 0 && a == 0 && b == 0)
      printf("%.10f\n", 1.0);
    else if (sum == 0 && a == 0)
      printf("%.10f\n", 0.5);
    else if (sum == 0 && b == 0)
      printf("%.10f\n", 1.0);
    else
      printf("%.10f\n", ans / sum);
  }
  return 0;
}
