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

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

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

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

k.z = m
k.s = b
l.u = j
l.s = j
b.q = j
b.u = d
j.u = l
j.s = l
d.q = j
d.u = b
m.z = k
m.s = d
assert m.s.q.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: C = None
        self.txt = txt

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

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

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

k.z = m
k.s = b
l.u = j
l.s = j
b.q = j
b.u = d
j.u = l
j.s = l
d.q = j
d.u = b
m.z = k
m.s = d
assert m.s.q.s.s.s.txt == "l"