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

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

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

l = A("l")
d = B("d")
n = C("n")

l.q = d
l.w = n
d.p = n
n.v = d
assert l.q.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: C = None
        self.txt = txt

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

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

l = A("l")
d = B("d")
n = C("n")

l.q = d
l.w = n
d.p = n
n.v = d
assert l.q.p.v.txt == "d"