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

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

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

l = A("l")
n = B("n")
k = C("k")
g = A("g")
f = B("f")
i = B("i")
m = B("m")
e = B("e")
c = B("c")
d = C("d")

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

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

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

l = A("l")
n = B("n")
k = C("k")
g = A("g")
f = B("f")
i = B("i")
m = B("m")
e = B("e")
c = B("c")
d = C("d")

l.t = d
n.r = e
n.t = i
k.z = d
k.t = e
k.w = g
g.t = d
f.r = n
f.t = e
i.r = m
i.t = e
m.r = e
m.t = e
e.r = i
e.t = n
c.r = n
c.t = m
d.z = k
d.t = e
d.w = l
assert k.t.t.r.t.t.t.txt == "e"