#include <bits/stdc++.h>
int a, b;
double A, B, whole, part, k;
int main(void) {
  int test;
  scanf("%d", &test);
  for (; test >= 1; test--) {
    scanf("%d %d", &a, &b);
    if (a == 0 && b == 0) {
      printf("1.0\n");
    } else if (a == 0 && b != 0) {
      printf("0.5\n");
    } else if (a != 0 && b == 0) {
      printf("1.0\n");
    } else {
      A = (double)a;
      B = (double)b;
      whole = 2 * A * B;
      if (B >= A / 4) {
        k = A / 4;
        part = A * B + A * k / 2;
      } else {
        k = 4 * B;
        part = 2 * A * B - B * k / 2;
      }
      printf("%lf\n", part / whole);
    }
  }
  return false;
}
