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

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

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

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

i = A("i")
c = B("c")
l = C("l")
h = D("h")
d = A("d")
n = C("n")
e = B("e")

i.w = c
i.t = l
i.p = n
c.p = e
l.r = n
h.t = n
d.w = c
d.t = n
d.p = n
n.r = l
e.p = c
assert n.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: C = None
        self.p: C = None
        self.txt = txt

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

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

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

i = A("i")
c = B("c")
l = C("l")
h = D("h")
d = A("d")
n = C("n")
e = B("e")

i.w = c
i.t = l
i.p = n
c.p = e
l.r = n
h.t = n
d.w = c
d.t = n
d.p = n
n.r = l
e.p = c
assert n.r.r.r.r.r.r.r.txt == "l"