#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
double x, y, n, m;
int t;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%lf%lf", &n, &m);
    if (m == 0)
      printf("1\n");
    else if (n > 4 * m)
      printf("%.10lf\n",
             (m * n + n * n / 8.0 - (n / 4.0 - m) * (n / 4.0 - m) * 2) /
                 (2.0 * n * m));
    else
      printf("%.10lf\n", (m + n / 8.0) / (2.0 * m));
  }
  return 0;
}
