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

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

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

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

n.r = d
k.s = i
k.w = d
i.p = h
i.t = d
j.p = h
j.t = d
d.p = h
d.t = i
b.r = d
h.s = i
h.w = j
assert b.r.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

n.r = d
k.s = i
k.w = d
i.p = h
i.t = d
j.p = h
j.t = d
d.p = h
d.t = i
b.r = d
h.s = i
h.w = j
assert b.r.p.s.p.s.txt == "i"