output_description: For each query, print "1" or "0".
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: def on_segment(u0, v0, u1, v1, u2, v2):
      return (
          u1 <= max(u0, u2)
          and u1 >= min(u0, u2)
          and v1 <= max(v0, v2)
          and v1 >= min(v0, v2)
      )
  
  
  def signed_area(x0, y0, x1, y1):
      return x0 * y1 - x1 * y0
  
  
  q = int(input())
  
  for _ in [0] * q:
      x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
      ta = signed_area(x1 - x0, y1 - y0, x2 - x0, y2 - y0)
      tb = signed_area(x1 - x0, y1 - y0, x3 - x0, y3 - y0)
      tc = signed_area(x3 - x2, y3 - y2, x0 - x2, y0 - y2)
      td = signed_area(x3 - x2, y3 - y2, x1 - x2, y1 - y2)
  
      """
      print(ta/2)
      print(tb/2)
      print(tc/2)
      print(td/2)
      
      print(on_segment(x0,y0,x2,y2,x1,y1))
      print(on_segment(x0,y0,x3,y3,x1,y1))
      print(on_segment(x2,y2,x0,y0,x3,y3))
      print(on_segment(x2,y2,x1,y1,x3,y3))
      """
  
      if ta * tb < 0 and tc * td < 0:
          print("1")
      elif ta == 0 and on_segment(x0, y0, x2, y2, x1, y1):
          print("1")
      elif tb == 0 and on_segment(x0, y0, x3, y3, x1, y1):
          print("1")
      elif tc == 0 and on_segment(x2, y2, x0, y0, x3, y3):
          print("1")
      elif td == 0 and on_segment(x2, y2, x1, y1, x3, y3):
          print("1")
      else:
          print("0")
  
problem_description: Intersection
  
    
  
  For given two segments s1 and s2, print "1" if they are intersect, "0"
  otherwise.
  
  s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and
  p3.
samples: [{"input": "3\n    0 0 3 0 1 1 2 -1\n    0 0 3 0 3 1 3 -1\n    0 0 3 0 3 -2 5 0", "output": "1\n    1\n    0"}]