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

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

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

k = A("k")
d = B("d")
i = C("i")
j = B("j")
n = A("n")

k.w = j
k.s = i
d.y = j
d.p = n
i.p = j
i.q = j
j.y = d
j.p = n
n.w = d
n.s = i
assert d.p.s.p.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: C = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
i = C("i")
j = B("j")
n = A("n")

k.w = j
k.s = i
d.y = j
d.p = n
i.p = j
i.q = j
j.y = d
j.p = n
n.w = d
n.s = i
assert d.p.s.p.p.s.txt == "i"