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

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

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

j = A("j")
e = B("e")
d = C("d")
l = B("l")
m = A("m")
a = A("a")
h = C("h")

j.t = m
j.z = l
e.z = a
e.q = l
d.t = h
d.v = e
l.z = a
l.q = e
m.t = a
m.z = l
a.t = j
a.z = l
h.t = d
h.v = e
assert j.z.q.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: B = None
        self.txt = txt

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

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

j = A("j")
e = B("e")
d = C("d")
l = B("l")
m = A("m")
a = A("a")
h = C("h")

j.t = m
j.z = l
e.z = a
e.q = l
d.t = h
d.v = e
l.z = a
l.q = e
m.t = a
m.z = l
a.t = j
a.z = l
h.t = d
h.v = e
assert j.z.q.z.z.z.z.txt == "l"