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

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

j = A("j")
d = B("d")
c = B("c")
b = B("b")
h = B("h")

j.v = b
j.z = b
d.t = j
d.v = b
c.t = j
c.v = d
b.t = j
b.v = h
h.t = j
h.v = c
assert b.v.v.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.z: B = None
        self.txt = txt

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

j = A("j")
d = B("d")
c = B("c")
b = B("b")
h = B("h")

j.v = b
j.z = b
d.t = j
d.v = b
c.t = j
c.v = d
b.t = j
b.v = h
h.t = j
h.v = c
assert b.v.v.v.t.txt == "j"