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

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

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

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

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

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

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

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

l.t = m
l.s = e
d.v = b
d.z = c
d.q = k
j.w = b
b.w = h
m.t = l
m.s = c
h.w = b
c.v = b
c.z = e
c.q = m
e.v = h
e.z = d
e.q = l
k.t = l
k.s = e
assert m.t.s.z.z.q.txt == "m"