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

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

k = A("k")
b = B("b")
c = A("c")
m = B("m")
f = B("f")
l = A("l")

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

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

k = A("k")
b = B("b")
c = A("c")
m = B("m")
f = B("f")
l = A("l")

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