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: B = None
        self.o: B = None
        self.txt = txt

k = A("k")
i = B("i")
h = B("h")
l = A("l")
f = B("f")
a = A("a")
n = A("n")

k.r = n
k.u = n
i.z = f
i.o = h
h.z = f
h.o = f
l.r = k
l.u = a
f.z = i
f.o = h
a.r = k
a.u = l
n.r = l
n.u = l
assert h.z.o.o.z.z.z.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: B = None
        self.o: B = None
        self.txt = txt

k = A("k")
i = B("i")
h = B("h")
l = A("l")
f = B("f")
a = A("a")
n = A("n")

k.r = n
k.u = n
i.z = f
i.o = h
h.z = f
h.o = f
l.r = k
l.u = a
f.z = i
f.o = h
a.r = k
a.u = l
n.r = l
n.u = l
assert h.z.o.o.z.z.z.txt == "i"