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

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

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

d = A("d")
b = B("b")
k = C("k")

d.p = b
b.v = k
k.q = b
assert k.q.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
k = C("k")

d.p = b
b.v = k
k.q = b
assert k.q.v.q.txt == "b"