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

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

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

c = A("c")
l = B("l")
j = C("j")
n = A("n")
i = C("i")
f = B("f")

c.w = j
l.p = j
l.s = i
l.q = f
j.y = i
j.r = f
n.w = i
i.y = j
i.r = l
f.p = j
f.s = j
f.q = l
assert j.r.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
j = C("j")
n = A("n")
i = C("i")
f = B("f")

c.w = j
l.p = j
l.s = i
l.q = f
j.y = i
j.r = f
n.w = i
i.y = j
i.r = l
f.p = j
f.s = j
f.q = l
assert j.r.q.q.txt == "f"