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

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

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

e = A("e")
a = B("a")
m = C("m")
b = C("b")

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

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

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

e = A("e")
a = B("a")
m = C("m")
b = C("b")

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