output_description: For each query, print the distance. The output values should be in a decimal
  fraction with an error less than 0.00000001.
input_description: The entire input looks like:
  
      
      
      q (the number of queries)
      1st query
      2nd query
      ...
      qth query
      
  
  Each query consists of integer coordinates of end points of s1 and s2 in the
  following format:
  
      
      
      xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3
attempt: import math
  
  
  class Point:
      def __init__(self, x, y):
          self.x = x
          self.y = y
  
      def distance(self, pnt):
          return math.sqrt((self.x - pnt.x) ** 2 + (self.y - pnt.y) ** 2)
  
  
  class Segment:
      def __init__(self, x1, y1, x2, y2):
          self.p1 = Point(x1, y1)
          self.p2 = Point(x2, y2)
          if self.p1.x == self.p2.x:
              self.a = float("inf")
              self.b = None
          else:
              self.a = (self.p1.y - self.p2.y) / (self.p1.x - self.p2.x)
              self.b = self.p1.y - self.a * self.p1.x
  
      def is_intersect(self, seg):
          a = (seg.p1.x - seg.p2.x) * (self.p1.y - seg.p1.y) + (seg.p1.y - seg.p2.y) * (
              seg.p1.x - self.p1.x
          )
          b = (seg.p1.x - seg.p2.x) * (self.p2.y - seg.p1.y) + (seg.p1.y - seg.p2.y) * (
              seg.p1.x - self.p2.x
          )
          c = (self.p1.x - self.p2.x) * (seg.p1.y - self.p1.y) + (
              self.p1.y - self.p2.y
          ) * (self.p1.x - seg.p1.x)
          d = (self.p1.x - self.p2.x) * (seg.p2.y - self.p1.y) + (
              self.p1.y - self.p2.y
          ) * (self.p1.x - seg.p2.x)
          e = (self.p1.x - seg.p1.x) * (self.p2.x - seg.p2.x)
          f = (self.p1.x - seg.p2.x) * (self.p2.x - seg.p1.x)
          g = (self.p1.y - seg.p1.y) * (self.p2.y - seg.p2.y)
          h = (self.p1.y - seg.p2.y) * (self.p2.y - seg.p1.y)
          return a * b <= 0 and c * d <= 0 and (e <= 0 or f <= 0) and (g <= 0 or h <= 0)
  
      def cross_point(self, seg):
          if self.is_intersect(seg) == False:
              return None
          if self.a == float("inf"):
              return self.p1.x, seg.a * self.p1.x + seg.b
          elif seg.a == float("inf"):
              return seg.p1.x, self.a * seg.p1.x + self.b
          else:
              x = -(self.b - seg.b) / (self.a - seg.a)
              y = seg.a * x + seg.b
              return x, y
  
      def distance_with_point(self, pnt):
          if self.a == float("inf"):
              return abs(pnt.x - self.p1.x)
          dist = abs(pnt.y - self.a * pnt.x - self.b) / math.sqrt(1 + self.a**2)
          a, b = pnt.distance(self.p1), pnt.distance(self.p2)
          lower_bound = min(a, b)
          if lower_bound < dist:
              return dist
          else:
              return lower_bound
  
      def distance(self, seg):
          if self.is_intersect(seg):
              return 0
          a = self.distance_with_point(seg.p1)
          b = self.distance_with_point(seg.p2)
          c = seg.distance_with_point(self.p1)
          d = seg.distance_with_point(self.p2)
          return min(a, b, c, d)
  
  
  q = int(input())
  for i in range(q):
      x0, y0, x1, y1, x2, y2, x3, y3 = list(map(int, input().split(" ")))
      line1, line2 = Segment(x0, y0, x1, y1), Segment(x2, y2, x3, y3)
      dist = line1.distance(line2)
      print("%.9f" % dist)
  
problem_description: Distance
  
    
  
  For given two segments s1 and s2, print the distance between them.
  
  s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and
  p3.
samples: [{"input": "0 0 1 0 0 1 1 1\n    0 0 1 0 2 1 1 2\n    -1 0 1 0 0 1 0 -1", "output": ".0000000000\n    1.4142135624\n    0.0000000000"}]