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

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

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

a = A("a")
i = B("i")
n = C("n")
b = B("b")
m = B("m")
e = A("e")
l = C("l")

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

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

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

a = A("a")
i = B("i")
n = C("n")
b = B("b")
m = B("m")
e = A("e")
l = C("l")

a.u = i
i.x = b
n.y = a
n.z = m
b.x = i
m.x = b
e.u = b
l.y = e
l.z = b
assert b.x.x.x.x.x.x.txt == "b"