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

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

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

d = A("d")
f = B("f")
a = C("a")
k = B("k")
m = B("m")
l = A("l")
n = B("n")
e = C("e")
h = A("h")

d.w = h
d.t = a
f.w = m
f.r = a
f.t = h
a.p = e
k.w = f
k.r = e
k.t = l
m.w = k
m.r = e
m.t = l
l.w = d
l.t = a
n.w = f
n.r = e
n.t = l
e.p = a
h.w = l
h.t = a
assert l.w.w.t.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: C = None
        self.txt = txt

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

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

d = A("d")
f = B("f")
a = C("a")
k = B("k")
m = B("m")
l = A("l")
n = B("n")
e = C("e")
h = A("h")

d.w = h
d.t = a
f.w = m
f.r = a
f.t = h
a.p = e
k.w = f
k.r = e
k.t = l
m.w = k
m.r = e
m.t = l
l.w = d
l.t = a
n.w = f
n.r = e
n.t = l
e.p = a
h.w = l
h.t = a
assert l.w.w.t.p.p.p.p.txt == "a"