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

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

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

j = A("j")
m = B("m")
l = C("l")
n = B("n")

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

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

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

j = A("j")
m = B("m")
l = C("l")
n = B("n")

j.v = l
j.q = m
m.r = l
m.w = n
l.z = m
l.p = j
n.r = l
n.w = m
assert l.p.q.r.txt == "l"