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

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

e = A("e")
l = B("l")
h = A("h")
d = B("d")

e.y = h
e.t = h
l.z = h
l.r = d
h.y = e
h.t = e
d.z = e
d.r = l
assert h.t.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: A = None
        self.txt = txt

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

e = A("e")
l = B("l")
h = A("h")
d = B("d")

e.y = h
e.t = h
l.z = h
l.r = d
h.y = e
h.t = e
d.z = e
d.r = l
assert h.t.y.t.y.txt == "h"