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

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

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

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

l.v = k
a.w = k
a.q = k
k.q = a
assert l.v.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

l.v = k
a.w = k
a.q = k
k.q = a
assert l.v.q.w.txt == "k"