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

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

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

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

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

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

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

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

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