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

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

e = A("e")
c = B("c")
l = B("l")
d = B("d")
f = B("f")
a = B("a")
h = A("h")

e.y = h
c.u = h
c.z = f
l.u = e
l.z = f
d.u = e
d.z = c
f.u = e
f.z = d
a.u = h
a.z = l
h.y = e
assert c.z.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
l = B("l")
d = B("d")
f = B("f")
a = B("a")
h = A("h")

e.y = h
c.u = h
c.z = f
l.u = e
l.z = f
d.u = e
d.z = c
f.u = e
f.z = d
a.u = h
a.z = l
h.y = e
assert c.z.u.y.txt == "h"