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

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

i = A("i")
c = B("c")
b = B("b")
l = A("l")
a = B("a")
m = B("m")
k = B("k")

i.r = a
c.z = a
b.z = a
l.r = a
a.z = m
m.z = c
k.z = a
assert i.r.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

i = A("i")
c = B("c")
b = B("b")
l = A("l")
a = B("a")
m = B("m")
k = B("k")

i.r = a
c.z = a
b.z = a
l.r = a
a.z = m
m.z = c
k.z = a
assert i.r.z.z.z.z.z.z.txt == "a"