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

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

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

k = A("k")
l = B("l")
c = C("c")

k.q = c
l.r = c
l.p = c
c.t = l
assert l.p.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
c = C("c")

k.q = c
l.r = c
l.p = c
c.t = l
assert l.p.t.r.txt == "c"