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

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

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

l = A("l")
g = B("g")
d = C("d")
m = C("m")
h = A("h")
b = A("b")
a = C("a")
e = B("e")
n = B("n")

l.t = g
l.z = b
g.r = e
d.y = l
d.u = m
m.y = l
m.u = d
h.t = e
h.z = b
b.t = e
b.z = l
a.y = b
a.u = m
e.r = g
n.r = g
assert l.z.t.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: A = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
d = C("d")
m = C("m")
h = A("h")
b = A("b")
a = C("a")
e = B("e")
n = B("n")

l.t = g
l.z = b
g.r = e
d.y = l
d.u = m
m.y = l
m.u = d
h.t = e
h.z = b
b.t = e
b.z = l
a.y = b
a.u = m
e.r = g
n.r = g
assert l.z.t.r.r.r.txt == "g"