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

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

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

a = A("a")
j = B("j")
c = C("c")
h = A("h")
d = A("d")
l = B("l")
b = B("b")
i = B("i")
n = A("n")
e = C("e")

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

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

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

a = A("a")
j = B("j")
c = C("c")
h = A("h")
d = A("d")
l = B("l")
b = B("b")
i = B("i")
n = A("n")
e = C("e")

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