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

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

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

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

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

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

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

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

l.t = h
c.p = h
h.r = m
m.t = h
a.t = b
b.r = m
e.t = h
j.p = b
d.p = b
assert c.p.r.t.r.t.r.t.txt == "h"