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

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

f = A("f")
m = B("m")
k = A("k")
i = B("i")
l = A("l")
j = A("j")
b = A("b")
h = B("h")

f.r = l
m.z = i
m.w = i
k.r = b
i.z = m
i.w = h
l.r = j
j.r = l
b.r = l
h.z = i
h.w = i
assert l.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

f = A("f")
m = B("m")
k = A("k")
i = B("i")
l = A("l")
j = A("j")
b = A("b")
h = B("h")

f.r = l
m.z = i
m.w = i
k.r = b
i.z = m
i.w = h
l.r = j
j.r = l
b.r = l
h.z = i
h.w = i
assert l.r.r.r.r.r.r.txt == "l"