Consider a 2d-grid. That is, each cell is identified by (i,j). You have received reports of two snake-sightings on this grid. You want to check whether they could be partial sightings of the same snake or not.
Each of the snake sightings correspond to a straight, axis-parallel line segment in the grid, and the starting and ending cells for each are given to you. Now consider a graph, where each cell in the 2d-grid is a vertex. And there is an edge between 2 vertices if and only if the cells corresponding to these two vertices are consecutive cells in at least one of the two snakes. That is, at least in one of the snakes, when you go from one end point to the other end point, these two cells should occur consecutively.
The two sightings/snakes are said to be same, if both these conditions are satisfied:
- The union of the set of cells in the first snake and the set of cells in the second snake, should form a connected component in this graph.
- No vertex should have degree more than 2 in the graph.
In other words, the induced subgraph on the union set must be a path graph.

-----Input-----
- The first line contains a single integer, T, which is the number of testcases. The description of each testcase follows.
- The first line of each testcase contains four integers: X11, Y11, X12, Y12. This represents the fact that the first snake's end points are (X11, Y11) and (X12, Y12).
- The second line of each testcase contains four integers: X21, Y21, X22, Y22. This represents the fact that the second snake's end points are (X21, Y21) and (X22, Y22).

-----Output-----
- For each testcase, output "yes" if the snakes are the same, as per the definition given above. Output "no" otherwise.

-----Constraints-----
- 1 ≤ T ≤ 105
- -109 ≤ Xij,Yij ≤ 109
- The two end points of every snake is guaranteed to be either on the same row or on the same column. Thus, the snake occupies all the cells between these cells, including the end points.

-----Example-----
Input:
4
2 1 8 1
11 1 7 1
2 1 8 1
11 1 9 1
2 1 8 1
3 1 3 -2
2 1 8 1
2 1 2 -2
Output:
yes
no
no
yes

-----Explanation-----
In the images, the first snake is red, the second snake is yellow, and the intersections, if any, are in orange.
The first test case corresponds to:

Both the conditions on the graph are satisfied, and hence this is a "yes".
The second test case corresponds to:

There is no edge between the vertex corresponding to the (8,1) cell and the vertex corresponding to (9,1), Hence, the union set is disconnected, and thus the answer is "no". 
The third test case corresponds to:

The vertex corresponding to the cell (3,1) has degree 3, which is more than 2, and thus the answer is "no". 
The fourth test case corresponds to:

Both the conditions on the graph are satisfied, and hence this is a "yes".

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# cook your dish here\nt=int(input())\nfor _ in range(t):\n x1,y1,x2,y2=map(int,input().split())\n x3,y3,x4,y4=map(int,input().split())\n if (x1==x3 and y1==y3)or(x2==x4 and y2==y4):\n  print("yes")\n elif (x1==x4 and y1==y4)or(x2==x3 and y2==y3):\n  print("yes")\n else:\n  if(y1==y2)and(y1==y3)and(y1==y4):\n   a1=max(x1,x2);a2=min(x1,x2)\n   b1=max(x3,x4);b2=min(x3,x4)\n   if a1>=b2 and a2<=b1:\n    print("yes")\n   else:\n    print("no")\n  elif (x1==x2)and(x1==x3)and(x1==x4):\n   a1=max(y1,y2);a2=min(y1,y2)\n   b1=max(y3,y4);b2=min(y3,y4)\n   if a1>=b2 and a2<=b1:\n    print("yes")\n   else:\n    print("no")\n  else:\n   print("no")'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13545