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

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

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

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

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

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

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

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

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