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

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

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

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

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

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

l.u = i
l.o = b
k.z = l
a.z = b
e.z = h
f.z = h
i.z = b
j.z = b
b.u = f
b.o = h
h.u = j
h.o = b
assert a.z.o.o.txt == "b"