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

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

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

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

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

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

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

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

e.z = d
e.q = m
m.q = h
h.u = c
d.z = j
d.q = c
j.z = e
j.q = m
l.u = m
c.q = l
assert m.q.u.q.txt == "l"