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

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

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

l = A("l")
d = B("d")
c = C("c")
e = B("e")
i = A("i")
m = A("m")
g = C("g")
h = B("h")
f = B("f")
b = B("b")

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

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

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

l = A("l")
d = B("d")
c = C("c")
e = B("e")
i = A("i")
m = A("m")
g = C("g")
h = B("h")
f = B("f")
b = B("b")

l.w = c
d.r = i
d.p = i
c.s = i
c.t = d
e.r = m
e.p = i
i.w = g
m.w = g
g.s = i
g.t = h
h.r = i
h.p = l
f.r = i
f.p = i
b.r = m
b.p = i
assert g.t.p.w.s.w.s.w.t.txt == "h"