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

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

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

i = A("i")
f = B("f")
d = C("d")
e = C("e")

i.u = d
i.x = e
f.y = e
f.v = e
f.w = d
d.p = e
d.u = e
e.p = d
e.u = d
assert d.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
d = C("d")
e = C("e")

i.u = d
i.x = e
f.y = e
f.v = e
f.w = d
d.p = e
d.u = e
e.p = d
e.u = d
assert d.u.u.u.u.txt == "d"