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

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

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

b = A("b")
e = B("e")
d = C("d")
k = A("k")
l = C("l")
h = B("h")
a = B("a")
c = B("c")
f = B("f")

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

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

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

b = A("b")
e = B("e")
d = C("d")
k = A("k")
l = C("l")
h = B("h")
a = B("a")
c = B("c")
f = B("f")

b.z = d
b.r = d
e.r = d
e.p = d
e.z = l
d.t = c
k.z = d
k.r = l
l.t = h
h.r = l
h.p = d
h.z = d
a.r = d
a.p = l
a.z = l
c.r = l
c.p = d
c.z = d
f.r = d
f.z = d
f.p = l
assert k.z.t.r.t.r.t.r.t.txt == "h"