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

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

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

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

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

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

f.z = l
f.r = h
c.u = h
i.u = h
h.u = m
m.u = c
l.z = f
l.r = h
k.z = f
k.r = h
assert m.u.u.u.txt == "m"