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

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

k = A("k")
e = B("e")
n = A("n")
l = B("l")
b = A("b")
h = A("h")
f = A("f")
i = B("i")
c = A("c")

k.x = i
e.o = i
e.z = b
n.x = e
l.o = i
l.z = h
b.x = l
h.x = e
f.x = l
i.o = e
i.z = k
c.x = i
assert n.x.o.o.z.x.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

k = A("k")
e = B("e")
n = A("n")
l = B("l")
b = A("b")
h = A("h")
f = A("f")
i = B("i")
c = A("c")

k.x = i
e.o = i
e.z = b
n.x = e
l.o = i
l.z = h
b.x = l
h.x = e
f.x = l
i.o = e
i.z = k
c.x = i
assert n.x.o.o.z.x.o.o.o.txt == "i"