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

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

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

a = A("a")
k = B("k")
b = C("b")
c = C("c")

a.y = k
a.u = k
k.u = c
b.v = k
c.v = k
assert c.v.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: B = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
b = C("b")
c = C("c")

a.y = k
a.u = k
k.u = c
b.v = k
c.v = k
assert c.v.u.v.u.txt == "c"