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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

m = A("m")
n = B("n")
f = C("f")
l = B("l")
g = A("g")
a = A("a")
d = B("d")
b = C("b")
i = B("i")

m.u = f
n.y = b
n.z = i
f.x = b
l.y = f
l.z = i
g.u = f
a.u = b
d.y = f
d.z = i
b.x = f
i.y = f
i.z = d
assert d.z.y.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

m = A("m")
n = B("n")
f = C("f")
l = B("l")
g = A("g")
a = A("a")
d = B("d")
b = C("b")
i = B("i")

m.u = f
n.y = b
n.z = i
f.x = b
l.y = f
l.z = i
g.u = f
a.u = b
d.y = f
d.z = i
b.x = f
i.y = f
i.z = d
assert d.z.y.x.x.x.txt == "b"