class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: A = None
        self.txt = txt

g = A("g")
h = B("h")
c = B("c")
i = B("i")
d = B("d")
n = B("n")
l = A("l")

g.y = n
g.x = n
h.t = n
h.v = l
c.t = h
c.v = g
i.t = d
i.v = l
d.t = h
d.v = g
n.t = c
n.v = l
l.y = d
l.x = i
assert l.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: A = None
        self.txt = txt

g = A("g")
h = B("h")
c = B("c")
i = B("i")
d = B("d")
n = B("n")
l = A("l")

g.y = n
g.x = n
h.t = n
h.v = l
c.t = h
c.v = g
i.t = d
i.v = l
d.t = h
d.v = g
n.t = c
n.v = l
l.y = d
l.x = i
assert l.x.t.t.txt == "h"